Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

347
Views
Spring Websocket: how to customize session disconnect message?

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:

  1. User logouts
  2. The corresponding session is invalidated in session repository
  3. 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.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!