close previous testConnect attempts (#4598)
* close previous testConnect attempts * remove onerror handler when canceling previous attempt Co-authored-by: Jeremy Letto <jeremy.letto@datasite.com>
This commit is contained in:
parent
4899b6cfef
commit
6d200d17b7
1 changed files with 13 additions and 0 deletions
|
@ -8,6 +8,8 @@ import { SessionPersistence } from '../persistence';
|
|||
|
||||
export class WebSocketService {
|
||||
private socket: WebSocket;
|
||||
private testSocket: WebSocket;
|
||||
|
||||
private webClient: WebClient;
|
||||
private keepAliveService: KeepAliveService;
|
||||
|
||||
|
@ -104,6 +106,11 @@ export class WebSocketService {
|
|||
}
|
||||
|
||||
private testWebSocket(url: string): void {
|
||||
if (this.testSocket) {
|
||||
this.testSocket.onerror = null;
|
||||
this.testSocket.close();
|
||||
}
|
||||
|
||||
const socket = new WebSocket(url);
|
||||
socket.binaryType = 'arraybuffer';
|
||||
|
||||
|
@ -118,5 +125,11 @@ export class WebSocketService {
|
|||
socket.onerror = () => {
|
||||
SessionPersistence.testConnectionFailed();
|
||||
};
|
||||
|
||||
socket.onclose = () => {
|
||||
this.testSocket = null;
|
||||
}
|
||||
|
||||
this.testSocket = socket;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue