I have a pretty stange error:
I was trying to test live chat made on websockets, but when the scripts loaded, I get this message in developer tools window: "WebSocket connection to 'wss://chat.mywebsite.com:80/testuser@wr94@34@0: Error in connection establishment: net::ERR_CONNECTION_CLOSED"
The error message in developer tools sends me to this line of code: wrc_socket = new WebSocket(_wsServerUrl+'/'+login+'@wr94@'+_id+'@'+_userType);
I was trying to figure out this issue with chat developers, and we found, that this issue is only happening on my computer where I'm working.
Same browsers, same network, same OS - I have the issue, everyone else don't have it. Apperently, something installed on my computer that blocks wss connections. But I can't figure out what exactly. Tryed disabling antivirus and windows firewall, no result.
I've tested with chrome, firefox and opera (all letest versions). When installed on my computer - they reproduce this error, when installed on collegue's computer (he sist just next to me in the same office) error not happening.
Also, I've tried this on my home computer and got even more strange result: Opera and Firefox reproduse the issue, and Chrome works fine.
Can you give me a hint or a direction to investigate this? I think it's related to certificates stuff, but don't know where to start.
The wss protocol establishes a WebSocket over an encrypted TLS connection, while the ws protocol uses an unencrypted connection. To establish the connection, the browser and server perform a WebSocket handshake over HTTP.
The most common cause of Websocket error is when you connect to DSS through a proxy. Websockets is a fairly recent protocol and many enterprise proxies do not support it. The websocket connection will not establish and you will see this message.
To create a secure (TLS/SSL) Websocket server with Node. js, we can use the https module. const WebSocket = require("ws"). Server; const { createServer } = require("https"); const fs = require("fs"); const server = createServer({ cert: fs.
wss://chat.mywebsite.com:80/
I'm pretty sure that you don't have wss://
configured on port 80. Port 80 is used by default for plain HTTP, i.e. http://
and ws://
and not https://
and wss://
. If the latter is available at all depends on your server configuration but simply trying wss://
on a port configured only for ws://
will not work.
If this works for other maybe they do it differently, that is they either use ws://chat.example.com
or wss://chat.example.com
but not wss://chat.example.com:80
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With