I really wonder if there is a way to customize a message in SESSION_EXPIRED_STATUS from WebSocketRegistryListener. The default implementation is follow:
static final CloseStatus SESSION_EXPIRED_STATUS = new CloseStatus(
CloseStatus.POLICY_VIOLATION.getCode(),
"This connection was established under an authenticated HTTP Session that has expired");
The Spring Security and Spring Session mechanisms are:
WebSocketRegistryListener catches SessionDestroyedEvent and closes all websocket sessions for previously destroyed http session (with close status SESSION_EXPIRED_STATUS) So, in my application I should customize such behavior, because not only the user can invalidate his session, but also admin is able to do it. Or session can be invalidated by timeout. And for every case I should send messages with different reasons. Can someone help me?
I found WebSocketSessionDecorator with close(CloseStatus status) but I don't know to add it to decorators list for websockets.