Websocket SSL connection

后端 未结 1 528
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 05:18

I am trying to test a secure websocket but I\'m having trouble. Here is my test:

var WebSocket = require(\'ws\');

describe(\'testing Web Socket\', function(         


        
相关标签:
1条回答
  • 2020-12-16 06:12

    The https module is rejecting your self-signed cert (as one would hope). You can force it to stop checking by passing a rejectUnauthorized: false option (which WebSocket will pass down to https):

    var ws = new WebSocket('wss://localhost:15449/', {
      protocolVersion: 8,
      origin: 'https://localhost:15449',
      rejectUnauthorized: false
    });
    
    0 讨论(0)
提交回复
热议问题