I'm not sure about Spring, but if you created your web socket code for the JSR-356 standard (which spring should understand), you can add a custom configurator to your endpoint definition where you can javax.websocket.server.ServerEndpointConfig.Configurator.modifyHandshake(ServerEndpointConfig, HandshakeRequest, HandshakeResponse) handshake. See javax.websocket.server.ServerEndpointConfig.Configurator.modifyHandshake(ServerEndpointConfig, HandshakeRequest, HandshakeResponse) , then you can access the actual session object, but it will depend on your application server. You can definitely get any parameters and headers.
This is an immediate answer, however the best design approach is to remove any session dependency first.
source share