<p dir="auto">[ yes ] I've searched for any related issues and avoided creating a duplicate<br>
issue.<br>
Description<br>
Announcement, it's not a bug probably。</p>
<p dir="auto">Firstly ,I run the standard wss ( ws over https server ) code by a single js file, It worked.<br>
and then , I copy the same code into the electron main.js, it can't be worked.<br>
so ,i open wireshark to capture the package , and then I found the electron svr send a little bytes other then never see any piece about how to handle the upgrade handshake. :(</p>
<p dir="auto">ps: i use the self-singed certification</p>
<p dir="auto">Reproducible in:<br>
version: ws ^7.1.2<br>
Node.js version(s): v10.16.1<br>
OS version(s): osx 10.14<br>
Steps to reproduce:<br>
1.server code :<br>
const fs = require('fs');<br>
const https = require('https');<br>
const WebSocket = require('ws');<br>
const path = require('path');</p>
<p dir="auto">const hostname = 'aaa.abc.com';<br>
const server = https.createServer({<br>
cert: fs.readFileSync(path.resolve(certs/${hostname}.crt)),<br>
key: fs.readFileSync(path.resolve(certs/${hostname}.key)),<br>
// rejectUnauthorized: false<br>
});<br>
const wss = new WebSocket.Server({ server });</p>
<p dir="auto">wss.on('connection', function connection(ws) {<br>
ws.on('message', function incoming(message) {<br>
console.log('received: %s', message);<br>
});<br>
ws.send('something');<br>
});</p>
<p dir="auto">server.listen(443,()=&gt;{<br>
console.log('start svr002')<br>
});</p>
<p dir="auto">client code<br>
ws=new WebSocket('wss://aaa.abc.com/echo',{<br>
rejectUnauthorized: false<br>
});<br>
ws.on('error',function (e) {<br>
connectFlag=false;<br>
console.error('error',e);<br>
ws=null;<br>
});</p>
<p dir="auto">ws.on('close',function (e) {<br>
connectFlag=false;<br>
console.warn('close',e)<br>
});</p>
<p dir="auto">ws.on('open', function open() {<br>
connectFlag=true;<br>
console.log('connected');<br>
ws.send('something');</p>
<p dir="auto">ws.on('message', function incoming(data) {<br>
console.log(data);<br>
});<br>
});</p>
<p dir="auto">run in single.js : yes<br>
node svr.js<br>
node cli001.js or open in ie,ff,chrome</p>
<p dir="auto">run embed in electron : not work<br>
electrion .<br>
node cli001.js or open in ie,ff,chrome</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/6058537/63348655-47dcc800-c38c-11e9-8a4b-14920f0a8184.jpg"><img src="https://user-images.githubusercontent.com/6058537/63348655-47dcc800-c38c-11e9-8a4b-14920f0a8184.jpg" alt="err" style="max-width: 100%;"></a></p>
<p dir="auto"><a href="https://i.imgur.com/mYtRTmJ.png" rel="nofollow">https://i.imgur.com/mYtRTmJ.png</a></p>
<p dir="auto"><a href="https://electronjs.org/docs/api/browser-window" rel="nofollow">https://electronjs.org/docs/api/browser-window</a></p>