diff --git a/app/components/SocketProvider.js b/app/components/SocketProvider.js index 6ffecf0a..a09f702e 100644 --- a/app/components/SocketProvider.js +++ b/app/components/SocketProvider.js @@ -36,7 +36,11 @@ class SocketProvider extends React.Component { componentDidMount() { this.socket = io(window.location.origin, { path: "/realtime", + transports: ["websocket"], + reconnectionDelay: 1000, + reconnectionDelayMax: 10000, }); + this.socket.authenticated = false; const { @@ -73,6 +77,12 @@ class SocketProvider extends React.Component { } }); + // on reconnection, reset the transports option, as the Websocket + // connection may have failed (caused by proxy, firewall, browser, ...) + this.socket.on("reconnect_attempt", () => { + this.socket.io.opts.transports = ["polling", "websocket"]; + }); + this.socket.on("authenticated", () => { this.socket.authenticated = true; });