joewalnes / reconnecting-websocket

A small decorator for the JavaScript WebSocket API that automatically reconnects
MIT License
4.24k stars 970 forks source link

How do I add request headers when I establish a websocket connection? #103

Open JieGz opened 5 years ago

JieGz commented 5 years ago

Hello, I need to carry a "token" message on the head of the request when I first establish a websocket connection. What should I do?

ciiiii commented 5 years ago

+1

thisismydesign commented 5 years ago

Also a blocking issue for me

alberto-f commented 5 years ago

WebSocket API does not provide any method for specifying additional headers.

In the link below, it says some ways to add token authentication https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api

I hope this helps.

Gr8z commented 5 years ago

image

I can do this in the ws package but not on this one, any idea why it's not supported?

PaulWieland commented 2 years ago

+1 for me. I am currently using faye-websocket which supports sending headers required for authentication.

Jacob273 commented 2 years ago

image

I can do this in the ws package but not on this one, any idea why it's not supported?

Thanks for posting this screenshot :)

Pesya1 commented 1 year ago

I have reconnecting-websocket with ws, how can I pass the headers?