Closed InstaRik closed 3 months ago
Please write a small test case using only ws
to reproduce the issue. The provided info is not very useful.
const { WebSocket } = require('ws');
const fs = require('fs');
socket = new WebSocket("wss://domain:25566", {
cert: fs.readFileSync('certs/wss/fullchain.pem'),
key: fs.readFileSync('certs/wss/privkey.pem'),
rejectUnauthorized: false,
handshakeTimeout: 10000
});
socket.on('open', () => {
console.log("[LOG Socket] Socket open!");
})
socket._req.on('socket', function (socket) {
socket.on('data', function (chunk) {
process.stdout.write(chunk.toString());
});
});
That connects every time for me. It's like this example https://github.com/websockets/ws/blob/master/examples/ssl.js. I can't reproduce the issue.
Ow wait is this maybe because im using let instead of const?
I'm closing this due to inactivity.
Is there an existing issue for this?
Description
Hi, I have an websocket server running in Java on a minecraft server. The websocket server is using a letsencrypt certificate. Before I started using the websocket without ssl/tls it didn't randomly connect, it always was connecting, now I am switching to Secure Websockets because of yes the security. Now when I start my websocket in nodejs (its in an discord bot). It won't connect every time. I need to restart the bot a couple of times before it succesfully connects to the secure websocket. What I find strange is when i CTRL C (SIGINT) the websocket server detects a new connection. And after 60s it was closed because of the lost connection detection.
ws version
^8.11.0
Node.js Version
v20.10.0
System
System: OS: Windows 11 10.0.22631 CPU: (12) x64 AMD Ryzen 5 5600 6-Core Processor Memory: 6.46 GB / 15.93 GB
Expected result
That the socket always connects not just randomly.
Actual result
When starting the discord bot (nodejs) the socket stays on CONNECTING STATE 0. Sometimes it goes through to state 1 connected. And upgrades to websocket secure.
Attachments
No response