Page 1 of 1

Best way to handle disconnects

Posted: Mon 25 Mar 2013 01:26
by jimmaguire
I want to handle network disconnects from a central location. I tried the OnConnectionLost event, but it does not get fired when I pull the cable from my router, but BeforeDisconnect does.

I see a TRetryMode in OnConnectionLost, but don't see it in help. What are the possible values?

I also see TConnLostCause, what's that for?

I'd like a list of events and corresponding actions I need to take to allow my app to keep running once a connection is lost and then the user clicks a Dialog to indicate he wants to retry.

Re: Best way to handle disconnects

Posted: Mon 25 Mar 2013 11:51
by AndreyZ
To make the OnConnectionLost event handler work, you should set the TIBCConnection.Options.LocalFailover property to True. Note that to use the OnConnectionLost event handler, you should add the MemData unit to the USES clause of your unit.
The OnConnectionLost event occurs only when the following conditions are fulfilled:
- a fatal error occurs (one of the following: network_error = 335544721 , lost_db_connection = 335544741, conn_lost = 335544648);
- there are no opened transactions in a connection that are not ReadOnlyReadCommitted;
- there are no opened and non-fetched datasets;
- there are no explicitly prepared datasets or SQLs.
Please make sure that none of the conditions above is violated.
Both TRetryMode and TConnLostCause enumerations are described in the IBDAC documentation. For more information, please read the IBDAC documentation.