From 0072d6a52e864de547f09f7d03ab847ec3a8f93e Mon Sep 17 00:00:00 2001 From: namanh-asher Date: Tue, 3 Oct 2023 17:03:00 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20can=20not=20reconnect=20websocket=20after?= =?UTF-8?q?=20turn=20off=20then=20turn=20on=20wifi.=20Thi=E2=80=A6=20(#755?= =?UTF-8?q?2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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,...) --- app/client/websocket/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/client/websocket/index.ts b/app/client/websocket/index.ts index 6a160a2ad..54ed13c05 100644 --- a/app/client/websocket/index.ts +++ b/app/client/websocket/index.ts @@ -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;