genesys-cloud-streaming-client 17.1.2-PCM-2352.6 → 17.1.2-develop.96

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.
@@ -16,7 +16,6 @@ export declare class Client extends EventEmitter {
16
16
  connecting: boolean;
17
17
  hardReconnectRequired: boolean;
18
18
  reconnectOnNoLongerSubscribed: boolean;
19
- useServerSidePings: boolean;
20
19
  logger: Logger;
21
20
  config: IClientConfig;
22
21
  isGuest: boolean;
@@ -56,7 +55,6 @@ export declare class Client extends EventEmitter {
56
55
  connect(connectOpts?: StreamingClientConnectOptions): Promise<void>;
57
56
  private backoffConnectRetryHandler;
58
57
  private makeConnectionAttempt;
59
- private setupConnectionMonitoring;
60
58
  private prepareForConnect;
61
59
  stopServerLogging(): void;
62
60
  startServerLogging(): void;
@@ -8,7 +8,6 @@ require("./polyfills");
8
8
  const notifications_1 = require("./notifications");
9
9
  const webrtc_1 = require("./webrtc");
10
10
  const ping_1 = require("./ping");
11
- const server_monitor_1 = require("./server-monitor");
12
11
  const utils_1 = require("./utils");
13
12
  const http_client_1 = require("./http-client");
14
13
  const events_1 = tslib_1.__importDefault(require("events"));
@@ -44,7 +43,6 @@ class Client extends events_1.default {
44
43
  this.hasMadeInitialAttempt = false;
45
44
  this.http = new http_client_1.HttpClient();
46
45
  this.reconnectOnNoLongerSubscribed = options.reconnectOnNoLongerSubscribed !== false;
47
- this.useServerSidePings = options.useServerSidePings !== false;
48
46
  this.config = {
49
47
  host: options.host,
50
48
  apiHost: options.apiHost || options.host.replace('wss://streaming.', ''),
@@ -177,12 +175,11 @@ class Client extends events_1.default {
177
175
  };
178
176
  }
179
177
  async handleStanzaDisconnectedEvent(disconnectedInstance) {
180
- var _a, _b;
178
+ var _a;
181
179
  this.logger.info('stanzaDisconnected event received', { stanzaInstanceId: disconnectedInstance.id, channelId: disconnectedInstance.channelId });
182
180
  this.connected = false;
183
181
  this.connecting = false;
184
182
  (_a = disconnectedInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
185
- (_b = disconnectedInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
186
183
  this.removeAllListeners(STANZA_DISCONNECTED);
187
184
  this.removeAllListeners(NO_LONGER_SUBSCRIBED);
188
185
  // unproxy events
@@ -196,20 +193,18 @@ class Client extends events_1.default {
196
193
  }
197
194
  }
198
195
  handleNoLongerSubscribed(stanzaInstance) {
199
- var _a, _b;
196
+ var _a;
200
197
  this.logger.warn('noLongerSubscribed event received', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
201
198
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
202
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
203
199
  this.hardReconnectRequired = true;
204
200
  if (!this.reconnectOnNoLongerSubscribed) {
205
201
  this.autoReconnect = false;
206
202
  }
207
203
  }
208
204
  handleDuplicateId(stanzaInstance) {
209
- var _a, _b;
205
+ var _a;
210
206
  this.logger.warn('duplicate_id event received, forcing hard reconnect', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
211
207
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
212
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
213
208
  this.hardReconnectRequired = true;
214
209
  }
215
210
  async disconnect() {
@@ -412,7 +407,7 @@ class Client extends events_1.default {
412
407
  return true;
413
408
  }
414
409
  async makeConnectionAttempt() {
415
- var _a, _b;
410
+ var _a;
416
411
  if (!navigator.onLine) {
417
412
  throw new offline_error_1.default('Browser is offline, skipping connection attempt');
418
413
  }
@@ -435,7 +430,7 @@ class Client extends events_1.default {
435
430
  extension.handleStanzaInstanceChange(stanzaInstance);
436
431
  }
437
432
  this.activeStanzaInstance = stanzaInstance;
438
- await this.setupConnectionMonitoring(stanzaInstance);
433
+ stanzaInstance.pinger = new ping_1.Ping(this, stanzaInstance);
439
434
  this.emit('connected');
440
435
  }
441
436
  catch (err) {
@@ -443,7 +438,6 @@ class Client extends events_1.default {
443
438
  this.logger.error('Error occurred in connection attempt, but after websocket connected. Cleaning up connection so backoff is respected', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
444
439
  this.removeStanzaBoundEventHandlers();
445
440
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
446
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
447
441
  await stanzaInstance.disconnect();
448
442
  this.connected = false;
449
443
  this.connecting = previousConnectingState;
@@ -451,26 +445,6 @@ class Client extends events_1.default {
451
445
  throw err;
452
446
  }
453
447
  }
454
- async setupConnectionMonitoring(stanzaInstance) {
455
- const setupClientPinger = (message) => {
456
- const logMessage = `$(message), falling back to client-side pinging`;
457
- this.logger.warn(logMessage, { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
458
- stanzaInstance.pinger = new ping_1.Ping(this, stanzaInstance);
459
- };
460
- if (this.useServerSidePings) {
461
- try {
462
- // if this fails, then hawk doesn't support serverside pinging and we need to do client side pings
463
- await stanzaInstance.subscribeToNode(this._notifications.pubsubHost, 'enable.server.side.pings');
464
- stanzaInstance.serverMonitor = new server_monitor_1.ServerMonitor(this, stanzaInstance);
465
- }
466
- catch (err) {
467
- setupClientPinger('failed to establish server-side pinging');
468
- }
469
- }
470
- else {
471
- setupClientPinger('client configured to not use server-side pinging');
472
- }
473
- }
474
448
  async prepareForConnect() {
475
449
  if (this.config.jwt) {
476
450
  this.hardReconnectRequired = false;
@@ -17,7 +17,6 @@ export interface IClientOptions {
17
17
  logLevel?: LogLevel;
18
18
  logFormatters?: LogFormatterFn[];
19
19
  signalIceConnected?: boolean;
20
- useServerSidePings?: boolean;
21
20
  appName?: string;
22
21
  appVersion?: string;
23
22
  appId?: string;
@@ -1,11 +1,9 @@
1
1
  import { Agent } from 'stanza';
2
2
  import { Ping } from '../ping';
3
- import { ServerMonitor } from '../server-monitor';
4
3
  export interface NamedAgent extends Omit<Agent, 'disconnect'> {
5
4
  id: string;
6
5
  channelId?: string;
7
6
  originalEmitter?: Function;
8
7
  pinger?: Ping;
9
- serverMonitor?: ServerMonitor;
10
8
  disconnect: () => Promise<void>;
11
9
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "developercenter-cdn/streaming-client",
3
- "version": "PCM-2352",
3
+ "version": "17.1.2",
4
4
  "ecosystem": "pc",
5
- "team": "Genesys Client Media (WebRTC)",
5
+ "team": "Client Streaming and Signaling",
6
6
  "indexFiles": [
7
7
  {
8
8
  "file": "v17.1.2/streaming-client.browser.ie.js"
@@ -17,6 +17,6 @@
17
17
  "file": "v17/streaming-client.browser.js"
18
18
  }
19
19
  ],
20
- "build": "6",
21
- "buildDate": "2024-04-22T20:45:17.448175Z"
20
+ "build": "96",
21
+ "buildDate": "2024-04-22T20:44:52.500279Z"
22
22
  }
@@ -16,7 +16,6 @@ export declare class Client extends EventEmitter {
16
16
  connecting: boolean;
17
17
  hardReconnectRequired: boolean;
18
18
  reconnectOnNoLongerSubscribed: boolean;
19
- useServerSidePings: boolean;
20
19
  logger: Logger;
21
20
  config: IClientConfig;
22
21
  isGuest: boolean;
@@ -56,7 +55,6 @@ export declare class Client extends EventEmitter {
56
55
  connect(connectOpts?: StreamingClientConnectOptions): Promise<void>;
57
56
  private backoffConnectRetryHandler;
58
57
  private makeConnectionAttempt;
59
- private setupConnectionMonitoring;
60
58
  private prepareForConnect;
61
59
  stopServerLogging(): void;
62
60
  startServerLogging(): void;
package/dist/es/client.js CHANGED
@@ -6,7 +6,6 @@ import './polyfills';
6
6
  import { Notifications } from './notifications';
7
7
  import { WebrtcExtension } from './webrtc';
8
8
  import { Ping } from './ping';
9
- import { ServerMonitor } from './server-monitor';
10
9
  import { delay, parseJwt, timeoutPromise } from './utils';
11
10
  import { HttpClient } from './http-client';
12
11
  import EventEmitter from 'events';
@@ -42,7 +41,6 @@ export class Client extends EventEmitter {
42
41
  this.hasMadeInitialAttempt = false;
43
42
  this.http = new HttpClient();
44
43
  this.reconnectOnNoLongerSubscribed = options.reconnectOnNoLongerSubscribed !== false;
45
- this.useServerSidePings = options.useServerSidePings !== false;
46
44
  this.config = {
47
45
  host: options.host,
48
46
  apiHost: options.apiHost || options.host.replace('wss://streaming.', ''),
@@ -175,13 +173,12 @@ export class Client extends EventEmitter {
175
173
  };
176
174
  }
177
175
  handleStanzaDisconnectedEvent(disconnectedInstance) {
178
- var _a, _b;
176
+ var _a;
179
177
  return __awaiter(this, void 0, void 0, function* () {
180
178
  this.logger.info('stanzaDisconnected event received', { stanzaInstanceId: disconnectedInstance.id, channelId: disconnectedInstance.channelId });
181
179
  this.connected = false;
182
180
  this.connecting = false;
183
181
  (_a = disconnectedInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
184
- (_b = disconnectedInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
185
182
  this.removeAllListeners(STANZA_DISCONNECTED);
186
183
  this.removeAllListeners(NO_LONGER_SUBSCRIBED);
187
184
  // unproxy events
@@ -196,20 +193,18 @@ export class Client extends EventEmitter {
196
193
  });
197
194
  }
198
195
  handleNoLongerSubscribed(stanzaInstance) {
199
- var _a, _b;
196
+ var _a;
200
197
  this.logger.warn('noLongerSubscribed event received', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
201
198
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
202
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
203
199
  this.hardReconnectRequired = true;
204
200
  if (!this.reconnectOnNoLongerSubscribed) {
205
201
  this.autoReconnect = false;
206
202
  }
207
203
  }
208
204
  handleDuplicateId(stanzaInstance) {
209
- var _a, _b;
205
+ var _a;
210
206
  this.logger.warn('duplicate_id event received, forcing hard reconnect', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
211
207
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
212
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
213
208
  this.hardReconnectRequired = true;
214
209
  }
215
210
  disconnect() {
@@ -418,7 +413,7 @@ export class Client extends EventEmitter {
418
413
  });
419
414
  }
420
415
  makeConnectionAttempt() {
421
- var _a, _b;
416
+ var _a;
422
417
  return __awaiter(this, void 0, void 0, function* () {
423
418
  if (!navigator.onLine) {
424
419
  throw new OfflineError('Browser is offline, skipping connection attempt');
@@ -442,7 +437,7 @@ export class Client extends EventEmitter {
442
437
  extension.handleStanzaInstanceChange(stanzaInstance);
443
438
  }
444
439
  this.activeStanzaInstance = stanzaInstance;
445
- yield this.setupConnectionMonitoring(stanzaInstance);
440
+ stanzaInstance.pinger = new Ping(this, stanzaInstance);
446
441
  this.emit('connected');
447
442
  }
448
443
  catch (err) {
@@ -450,7 +445,6 @@ export class Client extends EventEmitter {
450
445
  this.logger.error('Error occurred in connection attempt, but after websocket connected. Cleaning up connection so backoff is respected', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
451
446
  this.removeStanzaBoundEventHandlers();
452
447
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
453
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
454
448
  yield stanzaInstance.disconnect();
455
449
  this.connected = false;
456
450
  this.connecting = previousConnectingState;
@@ -459,28 +453,6 @@ export class Client extends EventEmitter {
459
453
  }
460
454
  });
461
455
  }
462
- setupConnectionMonitoring(stanzaInstance) {
463
- return __awaiter(this, void 0, void 0, function* () {
464
- const setupClientPinger = (message) => {
465
- const logMessage = `$(message), falling back to client-side pinging`;
466
- this.logger.warn(logMessage, { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
467
- stanzaInstance.pinger = new Ping(this, stanzaInstance);
468
- };
469
- if (this.useServerSidePings) {
470
- try {
471
- // if this fails, then hawk doesn't support serverside pinging and we need to do client side pings
472
- yield stanzaInstance.subscribeToNode(this._notifications.pubsubHost, 'enable.server.side.pings');
473
- stanzaInstance.serverMonitor = new ServerMonitor(this, stanzaInstance);
474
- }
475
- catch (err) {
476
- setupClientPinger('failed to establish server-side pinging');
477
- }
478
- }
479
- else {
480
- setupClientPinger('client configured to not use server-side pinging');
481
- }
482
- });
483
- }
484
456
  prepareForConnect() {
485
457
  return __awaiter(this, void 0, void 0, function* () {
486
458
  if (this.config.jwt) {
@@ -31444,45 +31444,6 @@ class Ping {
31444
31444
  }
31445
31445
  }
31446
31446
 
31447
- const DEFAULT_STANZA_TIMEOUT = 70 * 1000;
31448
- class ServerMonitor {
31449
- constructor(client, stanzaInstance, options = {}) {
31450
- this.client = client;
31451
- this.stanzaInstance = stanzaInstance;
31452
- this.stanzaTimeout = options.stanzaTimeout || DEFAULT_STANZA_TIMEOUT;
31453
- this.timeoutId = undefined;
31454
- this.start();
31455
- }
31456
- start() {
31457
- this.boundSetupStanzaTimeout = this.setupStanzaTimeout.bind(this);
31458
- this.client.on('connected', this.boundSetupStanzaTimeout);
31459
- this.stanzaInstance.on('raw:incoming', this.boundSetupStanzaTimeout);
31460
- }
31461
- stop() {
31462
- clearTimeout(this.timeoutId);
31463
- this.timeoutId = undefined;
31464
- if (this.boundSetupStanzaTimeout) {
31465
- this.client.off('connected', this.boundSetupStanzaTimeout);
31466
- this.stanzaInstance.off('raw:incoming', this.boundSetupStanzaTimeout);
31467
- this.boundSetupStanzaTimeout = undefined;
31468
- }
31469
- }
31470
- setupStanzaTimeout() {
31471
- clearTimeout(this.timeoutId);
31472
- this.timeoutId = setTimeout(() => {
31473
- const info = {
31474
- channelId: this.client.config.channelId,
31475
- jid: this.stanzaInstance.jid,
31476
- stanzaInstanceId: this.stanzaInstance.id,
31477
- timeout: this.stanzaTimeout
31478
- };
31479
- this.client.logger.error('Time between XMPP stanzas exceeded timeout, disconnecting', info);
31480
- this.stanzaInstance.sendStreamError({ text: 'time between stanzas exceeded timeout', condition: 'connection-timeout' });
31481
- this.stop();
31482
- }, this.stanzaTimeout);
31483
- }
31484
- }
31485
-
31486
31447
  var stanza = {};
31487
31448
 
31488
31449
  var Client$2 = {};
@@ -41483,7 +41444,6 @@ class Client extends EventEmitter {
41483
41444
  this.hasMadeInitialAttempt = false;
41484
41445
  this.http = new HttpClient();
41485
41446
  this.reconnectOnNoLongerSubscribed = options.reconnectOnNoLongerSubscribed !== false;
41486
- this.useServerSidePings = options.useServerSidePings !== false;
41487
41447
  this.config = {
41488
41448
  host: options.host,
41489
41449
  apiHost: options.apiHost || options.host.replace('wss://streaming.', ''),
@@ -41616,13 +41576,12 @@ class Client extends EventEmitter {
41616
41576
  };
41617
41577
  }
41618
41578
  handleStanzaDisconnectedEvent(disconnectedInstance) {
41619
- var _a, _b;
41579
+ var _a;
41620
41580
  return __awaiter$5(this, void 0, void 0, function* () {
41621
41581
  this.logger.info('stanzaDisconnected event received', { stanzaInstanceId: disconnectedInstance.id, channelId: disconnectedInstance.channelId });
41622
41582
  this.connected = false;
41623
41583
  this.connecting = false;
41624
41584
  (_a = disconnectedInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
41625
- (_b = disconnectedInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
41626
41585
  this.removeAllListeners(STANZA_DISCONNECTED);
41627
41586
  this.removeAllListeners(NO_LONGER_SUBSCRIBED);
41628
41587
  // unproxy events
@@ -41637,20 +41596,18 @@ class Client extends EventEmitter {
41637
41596
  });
41638
41597
  }
41639
41598
  handleNoLongerSubscribed(stanzaInstance) {
41640
- var _a, _b;
41599
+ var _a;
41641
41600
  this.logger.warn('noLongerSubscribed event received', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
41642
41601
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
41643
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
41644
41602
  this.hardReconnectRequired = true;
41645
41603
  if (!this.reconnectOnNoLongerSubscribed) {
41646
41604
  this.autoReconnect = false;
41647
41605
  }
41648
41606
  }
41649
41607
  handleDuplicateId(stanzaInstance) {
41650
- var _a, _b;
41608
+ var _a;
41651
41609
  this.logger.warn('duplicate_id event received, forcing hard reconnect', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
41652
41610
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
41653
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
41654
41611
  this.hardReconnectRequired = true;
41655
41612
  }
41656
41613
  disconnect() {
@@ -41859,7 +41816,7 @@ class Client extends EventEmitter {
41859
41816
  });
41860
41817
  }
41861
41818
  makeConnectionAttempt() {
41862
- var _a, _b;
41819
+ var _a;
41863
41820
  return __awaiter$5(this, void 0, void 0, function* () {
41864
41821
  if (!navigator.onLine) {
41865
41822
  throw new OfflineError('Browser is offline, skipping connection attempt');
@@ -41883,7 +41840,7 @@ class Client extends EventEmitter {
41883
41840
  extension.handleStanzaInstanceChange(stanzaInstance);
41884
41841
  }
41885
41842
  this.activeStanzaInstance = stanzaInstance;
41886
- yield this.setupConnectionMonitoring(stanzaInstance);
41843
+ stanzaInstance.pinger = new Ping(this, stanzaInstance);
41887
41844
  this.emit('connected');
41888
41845
  }
41889
41846
  catch (err) {
@@ -41891,7 +41848,6 @@ class Client extends EventEmitter {
41891
41848
  this.logger.error('Error occurred in connection attempt, but after websocket connected. Cleaning up connection so backoff is respected', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
41892
41849
  this.removeStanzaBoundEventHandlers();
41893
41850
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
41894
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
41895
41851
  yield stanzaInstance.disconnect();
41896
41852
  this.connected = false;
41897
41853
  this.connecting = previousConnectingState;
@@ -41900,28 +41856,6 @@ class Client extends EventEmitter {
41900
41856
  }
41901
41857
  });
41902
41858
  }
41903
- setupConnectionMonitoring(stanzaInstance) {
41904
- return __awaiter$5(this, void 0, void 0, function* () {
41905
- const setupClientPinger = (message) => {
41906
- const logMessage = `$(message), falling back to client-side pinging`;
41907
- this.logger.warn(logMessage, { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
41908
- stanzaInstance.pinger = new Ping(this, stanzaInstance);
41909
- };
41910
- if (this.useServerSidePings) {
41911
- try {
41912
- // if this fails, then hawk doesn't support serverside pinging and we need to do client side pings
41913
- yield stanzaInstance.subscribeToNode(this._notifications.pubsubHost, 'enable.server.side.pings');
41914
- stanzaInstance.serverMonitor = new ServerMonitor(this, stanzaInstance);
41915
- }
41916
- catch (err) {
41917
- setupClientPinger();
41918
- }
41919
- }
41920
- else {
41921
- setupClientPinger();
41922
- }
41923
- });
41924
- }
41925
41859
  prepareForConnect() {
41926
41860
  return __awaiter$5(this, void 0, void 0, function* () {
41927
41861
  if (this.config.jwt) {
@@ -17,7 +17,6 @@ export interface IClientOptions {
17
17
  logLevel?: LogLevel;
18
18
  logFormatters?: LogFormatterFn[];
19
19
  signalIceConnected?: boolean;
20
- useServerSidePings?: boolean;
21
20
  appName?: string;
22
21
  appVersion?: string;
23
22
  appId?: string;
@@ -1,11 +1,9 @@
1
1
  import { Agent } from 'stanza';
2
2
  import { Ping } from '../ping';
3
- import { ServerMonitor } from '../server-monitor';
4
3
  export interface NamedAgent extends Omit<Agent, 'disconnect'> {
5
4
  id: string;
6
5
  channelId?: string;
7
6
  originalEmitter?: Function;
8
7
  pinger?: Ping;
9
- serverMonitor?: ServerMonitor;
10
8
  disconnect: () => Promise<void>;
11
9
  }
@@ -5,8 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v17.1.2...HEAD)
8
- ### Changed
9
- * [PCM-2352](https://inindca.atlassian.net/browse/PCM-2352) - Use a timeout when using server-side pinging to detect when a connection has dropped
10
8
 
11
9
  # [v17.1.2](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v17.1.1...v17.1.2)
12
10
  * [NO-JIRA] - Removed Spigot testing from Jenkins build step.
@@ -16,7 +16,6 @@ export declare class Client extends EventEmitter {
16
16
  connecting: boolean;
17
17
  hardReconnectRequired: boolean;
18
18
  reconnectOnNoLongerSubscribed: boolean;
19
- useServerSidePings: boolean;
20
19
  logger: Logger;
21
20
  config: IClientConfig;
22
21
  isGuest: boolean;
@@ -56,7 +55,6 @@ export declare class Client extends EventEmitter {
56
55
  connect(connectOpts?: StreamingClientConnectOptions): Promise<void>;
57
56
  private backoffConnectRetryHandler;
58
57
  private makeConnectionAttempt;
59
- private setupConnectionMonitoring;
60
58
  private prepareForConnect;
61
59
  stopServerLogging(): void;
62
60
  startServerLogging(): void;
@@ -8,7 +8,6 @@ require("./polyfills");
8
8
  const notifications_1 = require("./notifications");
9
9
  const webrtc_1 = require("./webrtc");
10
10
  const ping_1 = require("./ping");
11
- const server_monitor_1 = require("./server-monitor");
12
11
  const utils_1 = require("./utils");
13
12
  const http_client_1 = require("./http-client");
14
13
  const events_1 = tslib_1.__importDefault(require("events"));
@@ -44,7 +43,6 @@ class Client extends events_1.default {
44
43
  this.hasMadeInitialAttempt = false;
45
44
  this.http = new http_client_1.HttpClient();
46
45
  this.reconnectOnNoLongerSubscribed = options.reconnectOnNoLongerSubscribed !== false;
47
- this.useServerSidePings = options.useServerSidePings !== false;
48
46
  this.config = {
49
47
  host: options.host,
50
48
  apiHost: options.apiHost || options.host.replace('wss://streaming.', ''),
@@ -177,12 +175,11 @@ class Client extends events_1.default {
177
175
  };
178
176
  }
179
177
  async handleStanzaDisconnectedEvent(disconnectedInstance) {
180
- var _a, _b;
178
+ var _a;
181
179
  this.logger.info('stanzaDisconnected event received', { stanzaInstanceId: disconnectedInstance.id, channelId: disconnectedInstance.channelId });
182
180
  this.connected = false;
183
181
  this.connecting = false;
184
182
  (_a = disconnectedInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
185
- (_b = disconnectedInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
186
183
  this.removeAllListeners(STANZA_DISCONNECTED);
187
184
  this.removeAllListeners(NO_LONGER_SUBSCRIBED);
188
185
  // unproxy events
@@ -196,20 +193,18 @@ class Client extends events_1.default {
196
193
  }
197
194
  }
198
195
  handleNoLongerSubscribed(stanzaInstance) {
199
- var _a, _b;
196
+ var _a;
200
197
  this.logger.warn('noLongerSubscribed event received', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
201
198
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
202
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
203
199
  this.hardReconnectRequired = true;
204
200
  if (!this.reconnectOnNoLongerSubscribed) {
205
201
  this.autoReconnect = false;
206
202
  }
207
203
  }
208
204
  handleDuplicateId(stanzaInstance) {
209
- var _a, _b;
205
+ var _a;
210
206
  this.logger.warn('duplicate_id event received, forcing hard reconnect', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
211
207
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
212
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
213
208
  this.hardReconnectRequired = true;
214
209
  }
215
210
  async disconnect() {
@@ -412,7 +407,7 @@ class Client extends events_1.default {
412
407
  return true;
413
408
  }
414
409
  async makeConnectionAttempt() {
415
- var _a, _b;
410
+ var _a;
416
411
  if (!navigator.onLine) {
417
412
  throw new offline_error_1.default('Browser is offline, skipping connection attempt');
418
413
  }
@@ -435,7 +430,7 @@ class Client extends events_1.default {
435
430
  extension.handleStanzaInstanceChange(stanzaInstance);
436
431
  }
437
432
  this.activeStanzaInstance = stanzaInstance;
438
- await this.setupConnectionMonitoring(stanzaInstance);
433
+ stanzaInstance.pinger = new ping_1.Ping(this, stanzaInstance);
439
434
  this.emit('connected');
440
435
  }
441
436
  catch (err) {
@@ -443,7 +438,6 @@ class Client extends events_1.default {
443
438
  this.logger.error('Error occurred in connection attempt, but after websocket connected. Cleaning up connection so backoff is respected', { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
444
439
  this.removeStanzaBoundEventHandlers();
445
440
  (_a = stanzaInstance.pinger) === null || _a === void 0 ? void 0 : _a.stop();
446
- (_b = stanzaInstance.serverMonitor) === null || _b === void 0 ? void 0 : _b.stop();
447
441
  await stanzaInstance.disconnect();
448
442
  this.connected = false;
449
443
  this.connecting = previousConnectingState;
@@ -451,26 +445,6 @@ class Client extends events_1.default {
451
445
  throw err;
452
446
  }
453
447
  }
454
- async setupConnectionMonitoring(stanzaInstance) {
455
- const setupClientPinger = (message) => {
456
- const logMessage = `$(message), falling back to client-side pinging`;
457
- this.logger.warn(logMessage, { stanzaInstanceId: stanzaInstance.id, channelId: stanzaInstance.channelId });
458
- stanzaInstance.pinger = new ping_1.Ping(this, stanzaInstance);
459
- };
460
- if (this.useServerSidePings) {
461
- try {
462
- // if this fails, then hawk doesn't support serverside pinging and we need to do client side pings
463
- await stanzaInstance.subscribeToNode(this._notifications.pubsubHost, 'enable.server.side.pings');
464
- stanzaInstance.serverMonitor = new server_monitor_1.ServerMonitor(this, stanzaInstance);
465
- }
466
- catch (err) {
467
- setupClientPinger('failed to establish server-side pinging');
468
- }
469
- }
470
- else {
471
- setupClientPinger('client configured to not use server-side pinging');
472
- }
473
- }
474
448
  async prepareForConnect() {
475
449
  if (this.config.jwt) {
476
450
  this.hardReconnectRequired = false;
@@ -17,7 +17,6 @@ export interface IClientOptions {
17
17
  logLevel?: LogLevel;
18
18
  logFormatters?: LogFormatterFn[];
19
19
  signalIceConnected?: boolean;
20
- useServerSidePings?: boolean;
21
20
  appName?: string;
22
21
  appVersion?: string;
23
22
  appId?: string;
@@ -1,11 +1,9 @@
1
1
  import { Agent } from 'stanza';
2
2
  import { Ping } from '../ping';
3
- import { ServerMonitor } from '../server-monitor';
4
3
  export interface NamedAgent extends Omit<Agent, 'disconnect'> {
5
4
  id: string;
6
5
  channelId?: string;
7
6
  originalEmitter?: Function;
8
7
  pinger?: Ping;
9
- serverMonitor?: ServerMonitor;
10
8
  disconnect: () => Promise<void>;
11
9
  }