I'm trying to establish connection (client side) with Web Socket which requires Basic Access Authentication. From documentation I know that I should use username and password with base64 encryption. It's node.js application so I decide to use npm package SockJS-client. It seems to be good solution because:
Under the hood SockJS tries to use native WebSockets first. If that fails it can use a variety of browser-specific transport protocols and presents them through WebSocket-like abstractions.
But I have no clue how to establish connection using Basic Access Authentication. I have tried solution from here, but this one
var ws = new WebSocket("ws://username:password@example.com/service");
does not work, I got an error like:
SyntaxError: The URL's scheme must be either 'http:' or 'https:'. 'ws:' is not allowed.
When I'm trying with http/https I got:
Error: InvalidStateError: The connection has not been established yet
When I'm trying to call
sock.send('test');
Another solutions like that below is impossible to implement because I have no access to server side of Web Socket.
var ws = new WebSocket("ws://example.com/service?key1=value1&key2=value2");
I have no idea how to correctly establish authenticated connection with Web Socket, if you know any solutions let me know.