Skip to content

Conversation

saurabhojha
Copy link

This pull request introduces support for custom headers in WebSocket connections to the NATS server. The key changes include:

Provision for supplying custom WebSocket request headers — developers can now attach additional HTTP headers (e.g., authorization tokens or tracing metadata) when establishing a WebSocket connection via NATS py.

A reference to a related issue in the .NET client repository (nats-io/nats.net#305) highlights the broader context and motivation for this enhancement.

Usage:
You can pass headers as a nats connection option ws_connection_headers.

nc = await nats.connect(
            "wss://localhost:8081",
            ws_connection_headers={
            "Authorization": ["Bearer SecureToken"],
            "X-TLS-Client": ["secure-client-v1"]
             }
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant