Websockets not working in Chrome (wss): “handshake

2019-04-24 19:59发布

问题:

I am currently developing a Websocket application on Docker Cloud. When redeploying my application and now I am always getting this error message:

WebSocket connection failed: WebSocket opening handshake was canceled

When looking into the data frame i see a single frame with this data:

(Opcode -1)

When researching the issue, it seems that is related to SSL / Certificates etc. Some solutions include adding self signed certificates. The confusing thing is that the same certificates seem to work for https but not for wss:

Also while testing with other browsers, I see that Safari is working fine. So I am sure that the server is actually running with the correct certificate on the correct port. Only chrome seems to have issues with it.

I know some solutions on stack overflow sugesst to add the certificate manually, but since it works on Safari and it is not a self signed certificate, I would assume it should just work.

回答1:

Checking the site against SSLabs shows that the server does not provide all needed parts of the certificate chain but misses a chain certificate:

This server's certificate chain is incomplete. Grade capped to B.
...
Chain issues Incomplete
...
2 Extra download - Let's Encrypt Authority X3

Once you resolved this issue by properly configuring the server it should work in all browsers. Currently it might work with some browsers only, i.e. if the browser has cached the missing chain certificate from visits to other sites (like Firefox does) or if it works around badly configured servers by downloading missing chain certificates (Chrome).