@resolveio/client-lib-core 15.1.5 → 15.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -276,7 +276,7 @@ class SocketService {
276
276
  this.onErrorHandler = (event) => {
277
277
  this.log(new Date(), 'WS', 'onerror', this, event);
278
278
  this.onerror(event);
279
- this.close();
279
+ this.reconnect();
280
280
  };
281
281
  document.addEventListener('visibilitychange', this.handleVisibilityChange.bind(this));
282
282
  }
@@ -286,13 +286,13 @@ class SocketService {
286
286
  this.connect();
287
287
  }
288
288
  connect() {
289
- if (!this.ws && this._storage.get('accessToken')) {
289
+ if (!this.ws && this.readyState !== WebSocket.CONNECTING && this._storage.get('accessToken')) {
290
+ this.readyState = WebSocket.CONNECTING;
291
+ this.readyState$.next(this.readyState);
290
292
  if (this.timeout) {
291
293
  clearTimeout(this.timeout);
292
294
  }
293
295
  this.ws = new WebSocket(this.url, this.protocols);
294
- this.readyState = WebSocket.CONNECTING;
295
- this.readyState$.next(this.readyState);
296
296
  this.onconnecting();
297
297
  this.log(new Date(), 'WS', 'attempt-connect', this.url);
298
298
  this.timeout = setTimeout(() => {
@@ -331,7 +331,7 @@ class SocketService {
331
331
  this.send('ping');
332
332
  this.pongTimeout = setTimeout(() => {
333
333
  this.log(new Date(), 'WS', 'pong not received, closing connection');
334
- this.close();
334
+ this.reconnect();
335
335
  }, this.pongTimeoutTime);
336
336
  }
337
337
  else {
@@ -385,10 +385,7 @@ class SocketService {
385
385
  }
386
386
  reconnect() {
387
387
  this.log(new Date(), 'WS', 'reconnect', this.readyState);
388
- if (this.readyState === WebSocket.CLOSED) {
389
- this.connect();
390
- }
391
- else if (this.readyState !== WebSocket.CONNECTING) {
388
+ if (this.readyState !== WebSocket.CONNECTING) {
392
389
  this.close();
393
390
  }
394
391
  }