'Websocket connection header Format
I am trying to write a code in NodeJS to make the websocket connection.
I send the following to create a new websocket connection
For Example:
wsLocation: ws://127.0.0.1:80/poll/31
wsProtocol:protocol1
wsCookie: -http-session-=41::http.session::9f9a4a003ae3088647ef019f789d753d;
But unable to make a websocket connection. I tried the below 4 formats
// Request1
// const ws = new WebSocket(wsLocation, wsProtocol, {
// headers: {
// Cookie: wsCookie,
// },
// });
// Request2
// const ws = new WebSocket(wsLocation, wsProtocol, {
// headers: {
// ["Cookie"]: wsCookie,
// },
// });
// Request3
// const ws = new WebSocket(wsLocation, wsProtocol, {
// headers: {
// ["Set-Cookie"]: wsCookie,
// },
// });
// Request4
// const ws = new WebSocket(wsLocation, wsProtocol, {
// headers: {
// "Set-Cookie": wsCookie,
// },
// });
None of them are working.
What is wrong in my request?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
