Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug websocket connection error with "Unknown reason"

Recently, I am getting the following message on chrome console;

WebSocket connection to 'ws://evo15:4008/?stream' failed: Unknown reason 

It's getting more and more and it's somehow annoying and I have to open a new tab or restart chrome every time to get back to normal websocket connection. How can I debug it? Unfortunately, I cannot reproduce it yet. My chrome version is Version 77.0.3865.75 (Official Build) (64-bit)

Update 1: I think you could reproduce it by closing the connection for a long time (I don't know the exact time) from server side and then open it and try to connect to it (client trys to connect every 1 sec). Then it will happen. So I guess there is an expire time or a limited number of tries to connect somewhere.

Update 2: It happens after 256 tries of reconnection.

WebSocket connection to 'ws://evo15:4008/?stream' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED 

After seeing 255 of this error on console, you will see the first error and cannot reconnect. So I think there is a 8 bit limit somewhere that I am missing

enter image description here

like image 336
Reza Avatar asked Sep 17 '19 12:09

Reza


People also ask

What causes WebSocket connection 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.


1 Answers

Looks like someone just filed this as a Chromium (v77) bug. See issue tracking it here.

Update 1: As noted in the issue tracker and comments below, this should now be fixed in the latest stable release, which is being rolled out now (2019/10/11).

Update 2: Despite the bug being marked as fixed/closed in monorail, canary (80.0.3977.4) still appears to have this behavior. As others have noted there is a global limit of 255. However, the fact that connections opened by JS don't get closed/reset when the page is refreshed still seems like a bug to me. screenshot of Chrome canary (version 80) demonstrating WebSocket limit / bug

like image 80
jacobq Avatar answered Sep 23 '22 07:09

jacobq