WebRTC signaling server Websocket connection closed in Chrome

1.7k Views Asked by At

I managed to deploy the WebRTC signaling server (https://github.com/andyet/signalmaster). And there is only one problem remaining For some reason, the connection does not work in Chrome. Chrome throws a warning:

WebSocket connection to '<wss://.......:8888/socket.io/?EIO=3&transport=websocket&sid=-OpElfbpa4_ZAGS9AAAK>' failed: WebSocket is closed before the connection is established.

Hovewer it works fine in Firefox. I set up the SSL certificates. Signaling server is running on EC2. Do you have any thoughts how to fix this?

1

There are 1 best solutions below

0
On

A few things to try that might solve the issue:

  • Are socket.io and socket.io-client the same version? If not, you should set them to the same version and try, since a mismatch can cause unstable behavior.

  • Try to modify the ping interval and the pong timeout, to detect if it is due to a timeout in the heartbeats because it takes longer on Chrome. You can do this with:

const io = require('socket.io')(http, {'pingInterval': 5000, 'pingTimeout': 10000});

(This would be 5 seconds interval and 10 seconds timeout, feel free to tweak this and see if it affects somehow).

  • Related to heartbeats check this answer too. Might be that there is no activity in the socket and thus socket.io closes the connection.

  • Another thing to check logs: while you are trying to establish the webrtc connection, open a new tab and go to chrome://webrtc-internals/ and see if you can check what is going on. If there are ICE Candidates, if not, if there is a pair of selected candidates, etc.

I hope some of this information helps.