#1 2019-04-12 09:55:35

Daniel
Member
Registered: 2016-12-08
Posts: 23

Using Keepalive ?

Both Synopse sockets and websockets seem to implement KeepAlive mechanism.
I'm using WebSockets and I'd like to make use of KeepAlive to detect disconnects.

I tried playing with the available properties but could not get it to do anything.

I assume that once connection is established any subsequent disconnect should be detected after keepAlive period expires.

So, what do I have to do/set for KeepAlive to be in use ?

Offline

#2 2019-04-12 11:58:23

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Using Keepalive ?

KeepAlive is for HTTP. It is just a wish from the client to not have the connection closed for a given time.
But most Web servers do close the connection after a while or a number of messages.
Then the connection is quickly re-opened at TCP level.

WebSockets have a more coherent mechanism, with proper disconnection and regular ping/pong messages to check the connection.
It will really keep alive the connection.

By default, if you use TSQLHttpClientWebsockets, this mechanism will be built-in.
If you want easy disconnection detection, e.g. to reconfigure some services when using asynchronous callbacks, check TDDDRestClientWebSockets from dddInfraApps.pas. Inherit from it, then override the DefineApplication and RegisterServices virtual methods.

Offline

Board footer

Powered by FluxBB