HTTP headers in Websockets client API

后端 未结 11 2355
情话喂你
情话喂你 2020-11-22 10:41

Looks like it\'s easy to add custom HTTP headers to your websocket client with any HTTP header client which supports this, but I can\'t find how to do it with the JSON API.

11条回答
  •  独厮守ぢ
    2020-11-22 11:06

    Technically, you will be sending these headers through the connect function before the protocol upgrade phase. This worked for me in a nodejs project:

    var WebSocketClient = require('websocket').client;
    var ws = new WebSocketClient();
    ws.connect(url, '', headers);
    

提交回复
热议问题