|
|
@@ -100,6 +100,18 @@ export default class BridgeChannel {
|
|
100
|
100
|
let timeoutS = 1;
|
|
101
|
101
|
|
|
102
|
102
|
const reload = () => {
|
|
|
103
|
+ const isConnecting = this._channel && (this._channel.readyState === 'connecting'
|
|
|
104
|
+ || this._channel.readyState === WebSocket.CONNECTING);
|
|
|
105
|
+
|
|
|
106
|
+ // Should not spawn new websockets while one is already trying to connect.
|
|
|
107
|
+ if (isConnecting) {
|
|
|
108
|
+ // Timeout is still required as there is flag `_areRetriesEnabled` that
|
|
|
109
|
+ // blocks new retrying cycles until any channel opens in current cycle.
|
|
|
110
|
+ this._retryTimeout = setTimeout(reload, timeoutS * 1000);
|
|
|
111
|
+
|
|
|
112
|
+ return;
|
|
|
113
|
+ }
|
|
|
114
|
+
|
|
103
|
115
|
if (this.isOpen()) {
|
|
104
|
116
|
return;
|
|
105
|
117
|
}
|
|
|
@@ -410,7 +422,13 @@ export default class BridgeChannel {
|
|
410
|
422
|
};
|
|
411
|
423
|
|
|
412
|
424
|
channel.onclose = event => {
|
|
413
|
|
- logger.info(`Channel closed by ${this._closedFromClient ? 'client' : 'server'}`);
|
|
|
425
|
+ logger.debug(`Channel closed by ${this._closedFromClient ? 'client' : 'server'}`);
|
|
|
426
|
+
|
|
|
427
|
+ if (channel !== this._channel) {
|
|
|
428
|
+ logger.debug('Skip close handler, channel instance is not equal to stored one');
|
|
|
429
|
+
|
|
|
430
|
+ return;
|
|
|
431
|
+ }
|
|
414
|
432
|
|
|
415
|
433
|
if (this._mode === 'websocket') {
|
|
416
|
434
|
if (!this._closedFromClient) {
|