Datasnap : Is there a way to detect connection loss globally?
Asked Answered
M

2

7

I'm looking to detect local connection loss. Is there a mean to do that, as with the events on the Corelabs components ?

Thanks

EDIT: Sorry, I'm going to try to be more specific: I'm currently designing a prototype using datasnap 2009. So I've got a thin client, a stateless server app and a database server.

What I would be able to do is to detect and handle connection loss (internet connectivity) between the client and the server app to handle it appropriately, ie: Display an informative error message to the user or to detect a server shutdown to silently redirect on another app server.

In 2-tier I used to manage that with ODAC components, the TOraSession have some events to handle this issues.

Morganatic answered 13/2, 2009 at 17:43 Comment(0)
D
4

Normally there is no event fired when a connection is broken, unless a statement is fired against the database. This is because there is no way of knowing a connection loss unless there is some sort of is-alive pinging going on.

Many frameworks check if a connection is still valid by doing a very small query against the server. Could be getting the time from a server. Especially in a connection pooling environment.

You can implement a connection checking function in your application in some of the database events (beforeexecute?). Or make a timer that checks every 10 seconds.

Dumfries answered 17/2, 2009 at 9:35 Comment(1)
I'm not sure that there is no way to detect the connection loss, because the connection loss of the underlying socket may be detectable. It is however true that most libraries have no event for it.Louiselouisette
B
1

Spawn a thread on the client which periodically sends some RPC 'Ping' or 'Heartbeat' commands to the server.

  • if this fails, the client knows that something happened to the connection

  • if the server does not hear the client anymore for some time period (for example, two times the heartbeat interval), he can conclude that the client disconnected, however this requires a stateful server (and your design is stateless so it would require event processing in a secondary system, which could be fed through a message queue)

Bootlace answered 15/7, 2011 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.