Skip to content

Set Sec-WebSocket-Protocol header to 'amqp' for WebSocket connections#183

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/set-sec-websocket-protocol
Draft

Set Sec-WebSocket-Protocol header to 'amqp' for WebSocket connections#183
Copilot wants to merge 2 commits intomainfrom
copilot/set-sec-websocket-protocol

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 16, 2026

The WebSocket client was not setting the Sec-WebSocket-Protocol header when establishing connections.

Changes

  • Pass "amqp" as the second parameter to the WebSocket constructor in AMQPWebSocketClient.connect()

This sets the standard WebSocket subprotocol header indicating AMQP protocol usage:

// Before
const socket = new WebSocket(this.url)

// After  
const socket = new WebSocket(this.url, "amqp")

The browser/client will now send Sec-WebSocket-Protocol: amqp in the HTTP upgrade request.

Original prompt

This section details on the original issue you should resolve

<issue_title>Set Sec-WebSocket-Protocol when connecting over websocket</issue_title>
<issue_description>The HTTP header Sec-WebSocket-Protocol should be set to 'amqp' when connecting over websocket. </issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: antondalgren <9164583+antondalgren@users.noreply.github.com>
@antondalgren
Copy link
Copy Markdown
Contributor

https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket#protocols
new WebSocket(url, protocols)

A single string or an array of strings representing the sub-protocol(s) that the client would like to use, in order of preference. If it is omitted, an empty array is used by default, i.e., [].

A single server can implement multiple WebSocket sub-protocols, and handle different types of interactions depending on the specified value. Note however that only one sub-protocol can be selected per connection.

The allowed values are those that can be specified in the Sec-WebSocket-Protocol HTTP header. These are values selected from the IANA WebSocket Subprotocol Name Registry, such as soap, wamp, ship and so on, or may be a custom name jointly understood by the client and the server.

Copilot AI changed the title [WIP] Set Sec-WebSocket-Protocol for websocket connections Set Sec-WebSocket-Protocol header to 'amqp' for WebSocket connections Jan 16, 2026
Copilot AI requested a review from antondalgren January 16, 2026 08:46
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.

Set Sec-WebSocket-Protocol when connecting over websocket

2 participants