This project is read-only.

RasDialer.Timeout does not work

Nov 4, 2013 at 2:39 PM
Edited Nov 4, 2013 at 6:08 PM
Hello, DotRas is great and it was fine until now.
But suddenly it turned out that RasDialer.Timeout does not work in my app. I create the terminal app with constant internet connection. Several days ago the first connection started to hold on and nothing were happening after RasDialer.DialAsync() call. When I set RasDialer.Timeout to 5000 there is no effect. It keeps dialing, the dialer is busy and no timeout events so I have to restart application to dial again. Finally it gets connected after restart but my app will not have human assistance. So what can it be and how to solve this problem?
There are no errors and exceptions to show you. The only indirect evidence I can rememver is that in Windows "Current connections" popup the connection being dialed has status "Dial" not "Is dialing" as usual. So it seems like RasDialer is dialing connection, but it does not change it's status in Windows. The entry name is the same I checked. So I expect RasDialer to fire a timeout event and create new good entry and dial it again but Timeout event is never fired. Please help?
Nov 5, 2013 at 5:22 AM
Under the hood it's just using a simple timer to hang-up the connection if the dialer is still considered busy within the allotted time. If hang-up is being called as expected (you should see a PostCompleted event being raised by RasDialer indicating that it timed out. If it's not raising the event that's one thing, but if it's raising the event appropriately it must be completing the HangUp call prior to that point.

If it's not releasing the connection that could be something else entirely. If Windows isn't letting the state of the connection change, it sounds like you've gotten your RAS state machine corrupted somehow by not properly disposing of the dialer or ensuring the application doesn't terminate before hanging up a connection attempt that's in progress. If the callback disappears from memory for whatever reason, the state machine hangs and won't let dialing continue (especially on older operating systems like XP or even Windows 7). This isn't a DotRas specific problem, it's just how the Win32 API works.
Nov 6, 2013 at 2:48 PM
Edited Nov 6, 2013 at 2:56 PM
Thank you for the answer Jeff.
I have some new input about this problem.
I was debugging all day long today and put dial/hang-up logic into the loop. Most of times the dotras dialer gets connected OK, but some times it gets frozen.
I logged every step of this operation and here are steps:
  • RasDialer.DialAsync()
  • right away RasDialer.IsBusy == true
  • ....some time of dialing until freeze...and
  • RasDialer.IsBusy == false !!!
  • RasConnection.GetActiveConnections() returns null
So! No events were fired form the RasDialer, no active connections were established and RasDialer.Timeout also was not involved when the RasDialer itself stopped dialing and changed it's status IsBusy to false.
And when I call RasDialer.DialAsync() after that freeze by hands (button click) the RasDialer gets connectd OK.
How can it be that the RasDialer looses its task to dial without any event notification back?
The only solution for me I see is to add my own timer to check RasDialer.IsBusy status and start DialAsync again if it's lost.
Yes, this is rough but what else can be done?
Nov 8, 2013 at 2:58 PM
When RasDialer thinks it's busy and isn't raising any events, what does Windows say the connection status is? Does Windows report it as connecting and never change state?
Nov 26, 2013 at 8:51 PM
For what it is worth, under certain rare circumstances which I don't understand, I've seen the "Connecting" state last arbitrarily long on cellular modems. (I don't use a timeout in my code per se, so I don't know if that makes a difference.)