title: WebSocket opening handshake was canceled for electron app on localhost
body: <p>I am not able to connect to wss on localhost. I have the following setup: </p>
  
  <p>I created certs using</p>
  
  <pre><code>openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
  </code></pre>
  
  <p>I started a wss server </p>
  
  <pre><code>const server = https.createServer({
    cert: fs.readFileSync('./cert.pem'),
    key: fs.readFileSync('./key.pem'),
    passphrase: 'ledtesting'
  });
  
  const wss = new WebSocket.Server({ server });
  
  server.listen(8000, 'localhost',function listening () {
    console.log(server.address().port);
    const ws = new WebSocket(`wss://localhost:${server.address().port}`, {
      rejectUnauthorized: false
    });
  });
  </code></pre>
  
  <p>I am running an electron app and have a webpage to connect to this web socket server using: </p>
  
  <pre><code>var localsockUrl = "wss://localhost:8000/";
  var localsocket = new WebSocket(localsockUrl);
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>connection to 'wss://localhost:8000/' failed: WebSocket opening handshake was canceled
  </code></pre>
  
  <p>How can I access the wss on localhost on an electron app? </p>