I am not able to connect to wss on localhost. I have the following setup:
I created certs using
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
I started a wss server
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
});
});
I am running an electron app and have a webpage to connect to this web socket server using:
var localsockUrl = "wss://localhost:8000/";
var localsocket = new WebSocket(localsockUrl);
I get the following error:
connection to 'wss://localhost:8000/' failed: WebSocket opening handshake was canceled
How can I access the wss on localhost on an electron app?