Skip to content

Reproducer for Vertx SockJS implementation, a websocket ping only prolongs the web session if a local session store is used, a clustered session store won't work

Notifications You must be signed in to change notification settings

cgm-aw/vertx-sessiontimeout-reproducer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

What is this?

Vertx provides a clustered session store and a local session store for web sessions. Vertx also provides support for web sockets via SockJS.

If you use the local session store, any web socket "PING" will extend the web session timeout. If you use the clustered session store, a different mechanism for the web session timeout is used and the mechanism to extend the timeout does not work.

How to use this

  1. Start de.apwolf.Main#main with useClusteredSessionStore=true
  2. After the backend has started, perform a REST request: http://localhost:8086/test
    1. You will see this log line: Received REST request on /test with session someId
  3. Open the sockjs client
    1. A web socket session will start, you will see this log line every 5 seconds: Received WS request SOCKET_PING for session someId
  4. Wait 2 minutes (the timeout for the session)
  5. Perform the same REST request again: http://localhost:8086/test
    → You will see a different session id

To see that it works with the local session store, redo all the steps with useClusteredSessionStore=false

Details

The web session timeout for a websocket ping is extended in io.vertx.ext.web.handler.sockjs.impl. EventBusBridgeImpl#internalHandlePing by calling io.vertx.ext.web.Session#setAccessed.

io.vertx.ext.web.sstore.impl.LocalSessionStoreImpl#handle checks Session#lastAccessed to evaluate whether a session was timed out, so everything works fine.

io.vertx.ext.web.sstore.impl.ClusteredSessionStoreImpl does not use Session#lastAccessed, it uses io.vertx.core.shareddata.AsyncMap and its internal TTL mechanism.
So the timeout extension performed by the event bus bridge is not honored and the session runs out although the websocket session is still open.

About

Reproducer for Vertx SockJS implementation, a websocket ping only prolongs the web session if a local session store is used, a clustered session store won't work

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published