[Logo] Enterprise Client Community
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Websocket Polling - Keep alive of connection  XML
Forum Index -> Development
Author Message
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5519
Offline

(from mail conversation)

Do websocket connections automatically send KeepAlive messages in CC?

Background: We have a customer who regularly loses the websocket connection. However, it is not logged directly. So the client log still sees an active connection.

I believe that the websocket connection is cut if nothing happens on it - hence the question: Can you configure keep-alive messages or do you already have that in place anyway?

Or would we have to/should we install something like this ourselves?

Björn Müller, CaptainCasa GmbH
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5519
Offline

Hi,

Web socket connections are NOT automatically managed so that they are kept alive.

There are two ways to keep them alive:

1. Use system.xml and do a corresponding definition:

Code:
 ...
     <!--
      **************************************************************************
      LONGPOLLING configuration
      
      keepaliveduration: duration in seconds after which a keep-alive-signal is sent so that
      the connection in not timed out. Use "-1" to not do any keep-alive management. 
      **************************************************************************
      -->     
     <longpolling keepaliveduration="180"/>
 ...
 


The default is "-1" so the automated keep-alive management needs to be explicitly activated.

2. Call method "keepAlive" periodically on each instance of "DefaultLongPollingWebSocket" on your own...

Of course 1. is much simpler, so only go for 2. when there is a good reason to do so...


One remark: the client processing will always create a new WebSocket connection when seeing that the current one was closed. The problem is that the websocket connection might be built up between quite a number of systems in reality, so some routers and proxies might be involved, each one potencially closing the connection to the next part after a certain duration of time... - which is not visible for the client side.

Kind regards! Björn

Björn Müller, CaptainCasa GmbH
rspiller

Power User

Joined: 20/04/2012 07:37:01
Messages: 59
Offline

Hi,

am I looking in the wrong place or does the configuration not work for websockets?

I set the keepaliveduration to 90 but in the browser-tools I only see a update message every 120 seconds.
At least if I look into the websocket cclongpolling connection an inside there into the message tab.

Wrong expectations or another issue?

greetz
Ruven
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5519
Offline

Hi,

the server's keep-alive-thread wakes up every 60 seconds, then checks which connections require a keep-alive-signal. So the granularity is minute-based...

Kind regards! Björn

Björn Müller, CaptainCasa GmbH
rspiller

Power User

Joined: 20/04/2012 07:37:01
Messages: 59
Offline

Hi,

all right!

But a little bit confusing. Setting the value to 90 or 60 both resulted in an actual heartbeat for every two minutes.

Setting it to 50 now generates a heartbeat every minute.
Maybe updating the template help text?

Why am I so picky? A customer has an apache http-deamon in front of the application and the timeout inside is set to 100 seconds.
So every two minutes does not help and therefore we need the heartbeat every minute as lowest possible value. Which is fine - when you know how to get it ;)

greetz
Ruven
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5519
Offline

Hi Ruven,

ok ok ok! ;-)

The server thread now wakes up every 15 seconds... (from next update on). And we in addition trigger the keep alive so that the definition that you define is met (i.e. if you define e.g. "95" then automatically the trigger is done every 90 seconds...)

Kind regards! Björn

Björn Müller, CaptainCasa GmbH
mametz



Joined: 14/09/2020 18:27:21
Messages: 3
Offline

Hi,

is there a java api to set the keepalive duration instead of using system.xml?

Kind regards
Matthias
CaptainCasa

Power User
[Avatar]

Joined: 21/11/2007 12:23:06
Messages: 5519
Offline

Hi,
there is no API - just by system.xml.
Of course you can call the keepAlive() method in the individual LongPolling-instance directly on your own.
Kind regards! Björn

Björn Müller, CaptainCasa GmbH
 
Forum Index -> Development
Go to:   
Powered by JForum 2.1.6 © JForum Team