Connection timeout isn’t working…

A strange thing happened a few days ago. Spent more than three hours trying to fix this damned thing…

Some time ago I have developed an application (SMSCentar was it’s name, iya, iya, oooo :) :) ) that it’s soul purpose was to automatically send and receive SMS messages via mobile phone connected to PC. It was an application developed in Borland Delphi 7 (ah the good old days when MS couldn’t even come close to Borland’s development tools :) ) and used a  mobile phone connected via RS232 cable to desktop PC. To be able to “manipulate” with that phone application had to send and receive AT commands to that mobile phone. As time passed by, that mobile phone got older, RS232 cables become history (hip-hip-hura for USB) and it was a matter of time before that application will become a relict of the past.

With mighty Visual Studio, .NET framework and Windows mobile there was not much to think about what to do with SMSCentar. Well, long and almost painful time of total 2 minutes was spent deciding SMSCentar is moving it’s source code to C# and Windows Mobile. And so my hair plucking with SQLConnection and Windows Mobile emulator begun…

The idea was to have an SQLCE database that would be a fall-back if my application lost it’s connection to main SQL server. Of course the nature of my code was when SQLConnection threw Exception to use SQLCE database. Default wait time to connect to main SQL server was way to long so connection string included “Connection timeout=2” and one would think that is all it’s needed for SQLConnection to wait 2 seconds for connection to main SQL server before an exception was thrown. But strangest thing happened… Application ignored Connection timeout parameter! It would wait for connection for default time and nothing seamed to work. I’ve been working with SQL server for ages and for the first time in my life I have witnessed that connection string parameter is ignored! Oh, the pain! Tried just about everything, from resetting windows mobile emulator (hard and soft), reinstalling .NET CE framework, reinstalling SQLCE to the point I was even thinking about reinstalling Visual Studio!

As most Windows mobile developers I debug my applications on Windows mobile emulator before deploying it to Windows Mobile device. SMSCentar is primarily developed for Windows Mobile 6 so it was being debugged in Windows Mobile 6 Professional emulator. Tried my application in Windows Mobile 6.1 emulator but the results were the same… Connection timeout just wasn’t working!

And with almost all my hair on the floor and almost none left on my head, I tried something that my mind couldn’t accept as a solution. I converted my application to Windows Mobile 6.5 and tried to debug it. And, guess what… Connection timeout worked! Application was waiting exactly 2 seconds for SQL Server connection and if it couldn’t connect started using it’s SQLCE database as a storage! With a question mark above my head and a few more ideas to try, I converted my application for Windows Mobile 5 Pocket PC Phone and deployed it to emulator. And once again Connection timeout worked! Hmm, it looks like it has something to do with Windows Mobile 6… And at last, reverted to my original source code for Windows Mobile 6 and instead deploying it to emulator I deployed it to Windows Mobile 6 Professional device and to my surprise when application started, Connection timeout was working!

Tried to find something on the Internet regarding this issue but nothing came around so it  must be something with my Windows Mobile 6 emulator images or… Well, after numerous re installations of emulator images Connection timeout still isn’t working but at least I don’t have to worry about it :)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.