Session timeout when WebSockets are enabled
Added by Claudio Crociati about 3 years ago
Hi, I'm testing the framework (3.6.0) and found a problem: using WtServlet.getConfiguration().setWebSocketsEnabled(true) the Tomcat session expires after session-timeout minutes (configured in web.xml session-config).
To reproduce the problem:
- add 5 in web.xml (non required, but the default timeout is 30 minutes, so you have to wait only 5 minutes before session timeout)
- start Tomcat
- open your browser and go to http://localhost:8080/jwt-hello: the application starts and works properly
- wait 5 minutes - I checked with Chrome developer tools and every 50 seconds a ping message is sent on the web socket
In Tomcat log shows up: INFO eu.webtoolkit.jwt.WtServlet - Session exiting: B3796147971B76E8C8FC6D68D8D181B0 (#sessions = 0)
then every 50 seconds: http-nio-8080-exec-7] INFO eu.webtoolkit.jwt.WebSocketSupport - WebSocket message discarded: could not retrieve web session
if I try to use the application the loading indicator appers in the top right corner but nothing happens.
Am I missing something or is it a bug?
RE: Session timeout when WebSockets are enabled - Added by Roel Standaert about 3 years ago
I think we're still missing a keep-alive mechanism for JWt when WebSockets are being used. We can't use WebSocket traffic to keep a session alive, but we'll still need to send HTTP messages from time to time just for that.