Fix can not reconnect websocket after turn off then turn on wifi. Thi… (#7552)

* Fix can not reconnect websocket after turn off then turn on wifi. This bug happen on some Samsung device (s10+, s20fe,...)

* Fix can not reconnect websocket after turn off then turn on wifi. This bug happen on some Samsung device (s10+, s20fe,...)

* Fix can not reconnect websocket after turn off then turn on wifi. This bug happen on some Samsung device (s10+, s20fe,...)
This commit is contained in:
namanh-asher 2023-10-03 17:03:00 +07:00 committed by GitHub
parent 28dc688fc3
commit 0072d6a52e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -136,6 +136,14 @@ export default class WebSocketClient {
// Check again if the client is the same, to avoid race conditions
if (this.conn === client) {
// In case turning on/off Wi-fi on Samsung devices
// the websocket will call onClose then onError then initialize again with readyState CLOSED, we need to open it again
if (this.conn.readyState === WebSocketReadyState.CLOSED) {
if (this.connectionTimeout) {
clearTimeout(this.connectionTimeout);
}
this.conn.open();
}
return;
}
this.conn = client;