pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.22k stars 197 forks source link

use of cookie header #35

Closed mschipperheyn closed 6 years ago

mschipperheyn commented 6 years ago

I use Spring Websocket on the server side and the version I work with, basically uses a sessionid to get into the authenticated areas. Is there a way to add a header that gets sent with the connection attempt?

pladaria commented 6 years ago

JS WebSocket API has no method to send additional headers https://html.spec.whatwg.org/multipage/web-sockets.html#network

This StackOverflow answer could be useful to you: https://stackoverflow.com/a/4361358/1430450

mschipperheyn commented 6 years ago

Yeah, unfortunately, that doesn't work in my case. React-native has an undocumented option that you can pass with a cookie header. https://stackoverflow.com/questions/46383628/how-to-use-react-natives-websocket-with-cookies