#1 2016-10-28 15:55:36

NJL
Member
Registered: 2015-04-22
Posts: 5

From client side, how to detect the server has gone away.

Hello,

I want to be able to detect when the server has gone away.  The client hangs when the server is shutdown and I want to try an display a notice of that event but I've been unable to find something I can poll to see the current state of the connection.

I initially tried polling the ServerTimeStampSynchronize function.  The client would lock up before that could return.  Then I attempted to look at the ServerInternalState variable value, but the client still locks before I can act upon it and it doesn't appear to update when the server is shutdown.

Is there some event that is fired on the client side when a connection interruption happens?  So I can more gracefully capture it and act upon it?

I've played some with changing the timeouts on my TSQLHttpClientWebsockets.Create but this did not seem to help the situation.

Thank you in advance.

Offline

#2 2016-11-02 13:45:41

NJL
Member
Registered: 2015-04-22
Posts: 5

Re: From client side, how to detect the server has gone away.

Has anyone else ran into this issue?

I also need to know this so I can handle if I've lost connection to the server to somehow cache the data being transacted locally and then feed it to the server once I'm able to talk to it again.  But if my application hangs when the server goes away I'm unable to create a solution for this.  Any guidance would be greatly appreciated.

Offline

#3 2016-11-02 16:27:14

edwinsn
Member
Registered: 2010-07-02
Posts: 1,215

Re: From client side, how to detect the server has gone away.

I think, you should use ServerTimeStampSynchronize, but just set the timeout when creating the client, for example, if in 0.5 second the ServerTimeStampSynchronize would not return, the connection would considered broken.

Hope it helps.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2016-11-10 22:18:20

erick
Member
Registered: 2015-09-09
Posts: 155

Re: From client side, how to detect the server has gone away.

NJL wrote:

Has anyone else ran into this issue?

>I also need to know this so I can handle if I've lost connection to the server to somehow cache the data being transacted locally and then feed it to the server once I'm able to talk to it again.  But if my application hangs when the server goes away I'm unable to create a solution for this.  Any guidance would be greatly appreciated.

I'm thinking of doing this by opening a websocket.  The server will  (probably) close the socket when it goes down gracefully, or the socket will close in time if the network connection fails (assuming keepalives).

E

Offline

Board footer

Powered by FluxBB