[undertow-dev] re. Idle timeout handling for websockets
by Sambasiva Rao Gaddipati
Hi all,
We have been having issues with how undertow handles idleTimeout for
websocket connections. We use undertow (2.1.1.Final) with wildfly (v 19.0)
In our service, undertow serves websocket connections for many devices in
the field. We want these connections to be always on. In the wildfly
configuration we set the default-session-timeout to -1. This overwrites the
expireTime of all sessions to -1 (which means never close the connection
because it is idle).
When wildfly instantiates undertow's session manger it does not enable
expireOldestUnusedSessionOnMax. So the eviction policies in the session
manager don't apply.
Over time (as devices are connecting and disconnecting) we see that the
InMemorySessionManager() builds up sessions.
As a work around, we schedule a call to session.invalidate(null) after some
delay when the onClose() websocket handler is called. But it seems
intrusive to call the internal api of the server from the business logic.
Is this a correct way of handling this. ?
One other solution that we considered, was to call
setMaxInactiveInterval(10) and let the session manger clean up the session
on expiry. But it turns out setMaxInactiveInterval() does not update the
expireTime of the session.
Please let me know your thoughts.
Thanks