'How to debug a failing websocket connection in Google Chrome

I want to connect a websocket from a web app to a server on our enterprise platform, for this I created a simple frontend and a simple websocket server to try things out.

Unfortunately, the application does not work in Google Chrome, but it does work in Firefox. I can also connect to the websocket correctly via Postman.

This is the line I use to connect to the websocket:

const socket = new WebSocket("wss://<host>/ws");

I then get a console error which looks like this:

WebSocket connection to 'wss://<host>/ws' failed:

There is no mention of what went wrong, and there is no additional information in the error event object. Inspecting socket reveals readyState = 3 as expected.

enter image description here

I've tried to get additional logs by launching chrome with debug logs like so:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-logging --v=9

But I only see the following line related to the error, nothing more.

[VERBOSE1:network_delegate.cc(34)] NetworkDelegate::NotifyBeforeURLRequest: wss://<host>/ws

Chrome version:

Google Chrome   99.0.4844.51 (Official Build) (x86_64) 
Revision    d537ec02474b5afe23684e7963d538896c63ac77-refs/branch-heads/4844@{#875}
OS  macOS Version 12.2.1 (Build 21D62)
JavaScript  V8 9.9.115.8

How do I debug this failing websocket connection? Why does it work in Firefox but not in Chrome?

Thanks a lot!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source