Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 17152e5

Browse files
fix: add error condition inside websocket class
1 parent 08d3a47 commit 17152e5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/configs/websocket/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class ApiManager {
7979
}, PING_INTERVAL);
8080
});
8181

82-
this.socket.onclose = () => {
82+
this.socket.addEventListener('close', () => {
8383
this.websocket_connected && this.websocket_connected(false);
8484
this.websocket_authorize && this.websocket_authorize(false);
8585
clearInterval(this.pingInterval);
@@ -91,7 +91,11 @@ export class ApiManager {
9191
window.alert('server down!!!');
9292
clearInterval(this.reconnectInterval);
9393
}
94-
};
94+
});
95+
96+
this.socket.addEventListener('error', () => {
97+
clearInterval(this.pingInterval);
98+
});
9599
}
96100

97101
public reset(appId: string, url: string, registerKeepAlive = false) {

0 commit comments

Comments
 (0)