# Need to specify subprotocol for WebSocket connection

**URL:** <https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466>\
**Category:** General\
**Created:** [26 March 2019 20:15 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466 "2019-03-26T20:15:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChipsNSalsa](https://avatars.discourse-cdn.com/v4/letter/c/c37758/32.png) [@ChipsNSalsa](https://discourse.nodered.org/u/ChipsNSalsa)\
**Post date:** [26 March 2019 20:15 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/1 "2019-03-26T20:15:42Z")

</div>

The server that I am working with requires the Sec-WebSocket-Protocol request header field be set to a non-standard (not registered) subprotocol in the client request to upgrade to WebSockets. No matter what I've tried, I can't seem to get that added to the header issued by a WebSocket node. Any suggestions?

---

<div class="post-metadata">

**Author:** ![alphie](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@alphie](https://discourse.nodered.org/u/alphie)\
**Post date:** [19 June 2020 18:48 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/2 "2020-06-19T18:48:46Z")

</div>

I'm having exactly the same problem. Did you ever find a solution?

To elaborate, when connecting from JavaScript, the call needs to look like this:

```auto
ws = new WebSocket("ws://myserver", ["protocolName"]);

```

Node-RED gets a 403 response because it can only do:

```auto
ws = new WebSocket("ws://myserver");

```

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [19 June 2020 19:12 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/3 "2020-06-19T19:12:20Z")

</div>

Hi @alphie, (and @ChipsNSalsa - my apologies for your question having gone unanswered for so long).

The WebSocket node doesn't provide any way to modify the headers of the request. There is an item on the backlog to allow it to do so, but it isn't something being looked currently.

---

<div class="post-metadata">

**Author:** ![alphie](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@alphie](https://discourse.nodered.org/u/alphie)\
**Post date:** [24 June 2020 23:47 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/4 "2020-06-24T23:47:15Z")

</div>

I solved my immediate problem by installing a modified version of the WebSocket node with the protocol value I needed hard-coded. It worked great. 15 seconds to modify the code, 2 hours to get it running in parallel to the production version. From this experience, I estimate it would take about 20 minutes of work to expose this parameter to the control panel.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [25 June 2020 03:11 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/5 "2020-06-25T03:11:28Z")

</div>

Very happy to consider a pull request. Thanks.

---

<div class="post-metadata">

**Author:** ![pasolution](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pasolution/32/29970_2.png) [@pasolution](https://discourse.nodered.org/u/pasolution)\
**Post date:** [9 October 2020 14:22 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/6 "2020-10-09T14:22:31Z")

</div>

The work on this change has been done back in Oct 2018, but has stalled in the approval process. [https://github.com/node-red/node-red/pull/1938](https://github.com/node-red/node-red/pull/1938) What can be done to get his approved?

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [9 October 2020 14:26 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/7 "2020-10-09T14:26:20Z")

</div>

It looks like we provided a bunch of feedback and the contributor may, or may not have acted on it - without a comment from them on its current state its hard to know.

If someone wanted to check it out and report back, that would certainly help move things along. It looks like it'll need rebasing on the latest code and some merge conflicts sorting out as well.

---

<div class="post-metadata">

**Author:** ![Alex96](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Alex96](https://discourse.nodered.org/u/Alex96)\
**Post date:** [5 January 2021 20:29 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/8 "2021-01-05T20:29:05Z")

</div>

Hi Alphie, could you give more steps on how-to hard-code? Thx.

---

<div class="post-metadata">

**Author:** ![excalaibur](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@excalaibur](https://discourse.nodered.org/u/excalaibur)\
**Post date:** [11 August 2021 02:30 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/9 "2021-08-11T02:30:45Z")

</div>

Hi,

I also have the same problem! I tested in Firecamp websocket. I need to specify the protocol in "config" tab to get connected to the server.

Node-Red Websocket node does not have a field currently for me to enter this protocol name.

Is there any temporary solution now. Or in the future?

really look forward to have this option! THANKS.

Tom

---

<div class="post-metadata">

**Author:** ![wittyhat](https://avatars.discourse-cdn.com/v4/letter/w/f07891/32.png) [@wittyhat](https://discourse.nodered.org/u/wittyhat)\
**Post date:** [2 January 2022 17:05 UTC](https://discourse.nodered.org/t/need-to-specify-subprotocol-for-websocket-connection/9466/10 "2022-01-02T17:05:55Z")

</div>

Hi everyone - is there any way to sponsor this issue/PR? I need this feature for my use-case, and I'd be happy to put some $ toward the work required to get it rebased/reviewed and merged
