mirror of
https://github.com/owncast/owncast.git
synced 2024-11-23 13:24:33 +03:00
Fix websocket reconnection (#3959)
The `onerror` event is only triggered if the buffer is full while the socket is closed, while the `onclose` event is called for any kind of disconnection: https://websockets.spec.whatwg.org/#closeWebSocket Fixes: https://github.com/owncast/owncast/issues/3958 Co-authored-by: Alyssa Ross <hi@alyssa.is>
This commit is contained in:
parent
45392aa5ad
commit
2015a566cb
1 changed files with 4 additions and 6 deletions
|
@ -56,7 +56,7 @@ export default class WebsocketService {
|
||||||
|
|
||||||
const ws = new WebSocket(url.toString());
|
const ws = new WebSocket(url.toString());
|
||||||
ws.onopen = this.onOpen.bind(this);
|
ws.onopen = this.onOpen.bind(this);
|
||||||
ws.onerror = this.onError.bind(this);
|
ws.onclose = this.onClose.bind(this);
|
||||||
ws.onmessage = this.onMessage.bind(this);
|
ws.onmessage = this.onMessage.bind(this);
|
||||||
|
|
||||||
this.websocket = ws;
|
this.websocket = ws;
|
||||||
|
@ -70,12 +70,10 @@ export default class WebsocketService {
|
||||||
this.backOff = 0;
|
this.backOff = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On ws error just close the socket and let it re-connect again for now.
|
onClose() {
|
||||||
onError() {
|
if (!this.isShutdown) {
|
||||||
handleNetworkingError();
|
handleNetworkingError();
|
||||||
this.socketDisconnected();
|
this.socketDisconnected();
|
||||||
this.websocket.close();
|
|
||||||
if (!this.isShutdown) {
|
|
||||||
this.scheduleReconnect();
|
this.scheduleReconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue