Reconnect or test connection question

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Reconnect or test connection question

Post by MJFShark »

Hi All!

I have a situation where I'm getting a disconnected connection despite doing some attempted keep-alive pinging to the server (in this case with the OLEDB protocol to SQLServer.) What's the recommended way to handle this kind of thing as far as figuring out that it's disconnected and then reconnecting gracefully. I see that there's a ZConn.Reconnect method but I'm not sure if that can be called in a preventative way. I guess my question is how to detect that the connection has been dropped. Thanks for any suggestions!

-Mark
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 797
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Reconnect or test connection question

Post by aehimself »

That is the exact way of doing it. I have a one-minute timer in my application which pings the endpoint, and in my main exception handler (which is assigned to Application.OnException too) I'm keeping an eye on disconnect exceptions to know when I should reconnect.

See viewtopic.php?f=50&t=138572, might be relevant to you too.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
MJFShark
Expert Boarder
Expert Boarder
Posts: 218
Joined: 04.06.2020, 13:59

Re: Reconnect or test connection question

Post by MJFShark »

Awesome, thanks for the tips!

-Mark
Post Reply