You can not send custom header when you want to establish WebSockets connection using JavaScript WebSockets API.
You can use Subprotocols
headers by using the second WebSocket class constructor:
var ws = new WebSocket("ws://example.com/service", "soap");
and then you can get the Subprotocols headers using Sec-WebSocket-Protocol
key on the server.
There is also a limitation, your Subprotocols headers values can not contain a comma (,
) !