Skip to content

Session Object from WebSocket Events #273

Closed

Description

@kondavivek

Through WebSocket Events Is there any way we can get the WebSocketSession Object so that we can pass it on to WebSocketHandler functions.

It would also be helpful If there is any other event that can get me the session object.

Activity

  1. darklight3it commented on May 26, 2026

    @darklight3it
    Collaborator

    Hello @kondavivek,

    Sorry if this issue has been open for so long. Reading your message here, it seems to me that you are trying to get something equivalent to Spring's WebSocketSession — a live connection object you can pass to WebSocketHandler functions and call sendMessage() on directly. Is that correct?

    If so, that's not possible in Lambda. API Gateway owns the WebSocket connection, and Lambda is invoked statelessly per message. There's no persistent server-side socket to wrap in a session object. To send messages back to a connected client, you use the API Gateway Management API with the connectionId from event.getRequestContext().getConnectionId().

    If you had something else in mind, let me know and I can reopen this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions