WebSocket opening handshake was canceled

In Chrome, I have a problem with the WebSocket connection:

wss:// failed: WebSocket opening handshake was canceled

In the other browsers all is working well.

What can I do?

Upvotes: 3

Views: 10153

Answers (2)

Michal M
Michal M

Reputation: 1568

Not sure if that was the op's case, but if you came here and have the very specific combo of:

  • Optional TLS client certificate validation enabled in your reverse proxy (e.g. the verifyclientcertifGiven option in Traefik, or enabled by default in some other reverse proxies)
  • Secure WebSocket endpoint on a host that is not otherwise accessed through the browser (or if you just use the WSS endpoint in a WebKit-based web view)
  • See the result of WebSocket opening handshake was canceled while everything works well in other browsers and clients

You may be hitting a long-standing bug in Chromium (WebKit?): https://bugs.chromium.org/p/chromium/issues/detail?id=329884

This github issue and discussion (not really related to the actual project in which it is reported) https://github.com/beyondcode/laravel-websockets/issues/187 also tackles the problem quite well.

One possible solution would be to disable the optional client certificate verification, e.g. just not use it, or split the single host (which either requires the client cert of not) to two hosts, one which does no client cert validation and the other that does it mandatorily.

Upvotes: 2

Darin
Darin

Reputation: 508

I'm guessing that you're trying to connect to localhost or another non-public IP address (192.168, etc). Chrome blocks these requests due to security concerns about possible war-dialing from pages downloaded from the internet. See https://news.ycombinator.com/item?id=9210484

Actually my initial diagnosis was wrong. I had the same problem with a wildcard certificate. Issuing a specific certificate to the domain from letsencrypt solved the problem.

Upvotes: 1

Related Questions