Skip to content

Feature request: Built-in WebSocket ping/pong support (or access to connection for custom implementation) #397

@akorosi

Description

@akorosi

Hi maintainers,

I'm currently using the opamp-go/server package to implement a custom OpAMP Server (running behind an AWS ALB via ECS Fargate). One issue we're facing is that if the server task is replaced, the WebSocket connection remains silently broken for a long time (10 minutes), as the client is unaware that the connection is dead.

To handle this gracefully, we would need a WebSocket ping/pong mechanism.

Background
The WebSocket protocol itself natively supports ping and pong control frames, which are intended exactly for this purpose: to check if a connection is still alive and to keep it open. The Go WebSocket implementation (gorilla/websocket) used internally by opamp-go already has built-in methods such as WriteControl(websocket.PingMessage, ...), SetPongHandler(), and SetReadDeadline() to support this functionality.

Feature request
Please consider adding built-in WebSocket ping/pong handling to the OpAMP server.

How this could be implemented
After upgrading the HTTP connection to WebSocket, the server could periodically send Ping control frames using conn.WriteControl(websocket.PingMessage, ...).

The server should set a PongHandler via conn.SetPongHandler(...) to update read deadlines and confirm the connection is alive.

Read deadlines (conn.SetReadDeadline(...)) should be set and updated to avoid blocking reads indefinitely on dead connections.

These parameters (ping interval, pong timeout) should be configurable via server.Settings.

Alternative request (fallback)
If built-in ping/pong is not feasible, please provide a way to expose the underlying WebSocket connection (e.g., *websocket.Conn) so that the users of opamp-go can implement custom ping/pong logic and connection management externally.

Allow injection of a custom WebSocket upgrader or connection handler.

Thank you for considering this request!

Cheers,
Adam

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions