Subject Re: [IBO] best database reconnect approach
Author Markus Ostenried
On 1/4/07, Alan McDonald <alan@...> wrote:
> > I have a two tier FireBird based application using IB Objects
> > 4.5...What would be the best way to handle network connection loss and
> > how to reconnect? I have tried handling various events of Connection
> > component but it doesnt work...
> >
> > Thanks alot,
> > Eugene.
> >
>
> a LAN? how often is this happening? if it's frequent, surely there's a
> hardware issue that needs solving?
> Alan

We have this problem, too, with clients using WLAN which seems to
cause Firebird connection losses quite frequently - at least at one
client with bad WLAN connectivity.

You can determine a connection loss in the TIB_Connection.OnError
event like this:

if IB_Session.ConnectionLostErrcode(ERRCODE) then DoStuff;

But since the OnError event might be called from within an exception
you cannot to the reconnect from within this event handler. Instead
you can enable a timer, and when that timer fires you can disable the
timer, force a disconnect, and then do the reconnect:

IB_Connection.ForceDisconnect;
IB_Connection.Connect;

HTH,
Markus