Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebSocket connection to 'wss://...' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED

Tags:

ssl

websocket

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.

like image 803
JackHammer Avatar asked Dec 07 '15 11:12

JackHammer


People also ask

What is WSS Websockets?

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.

What causes WebSocket error?

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.

How do I setup a TLS certificate for my local WebSocket server?

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.


1 Answers

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.

like image 140
Steffen Ullrich Avatar answered Jun 20 '23 15:06

Steffen Ullrich