@webex/plugin-meetings 3.3.1-next.2 → 3.3.1-next.21

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.
Files changed (56) hide show
  1. package/dist/breakouts/breakout.js +1 -1
  2. package/dist/breakouts/index.js +7 -2
  3. package/dist/breakouts/index.js.map +1 -1
  4. package/dist/interpretation/index.js +1 -1
  5. package/dist/interpretation/siLanguage.js +1 -1
  6. package/dist/media/MediaConnectionAwaiter.js +50 -13
  7. package/dist/media/MediaConnectionAwaiter.js.map +1 -1
  8. package/dist/mediaQualityMetrics/config.js +16 -6
  9. package/dist/mediaQualityMetrics/config.js.map +1 -1
  10. package/dist/meeting/connectionStateHandler.js +67 -0
  11. package/dist/meeting/connectionStateHandler.js.map +1 -0
  12. package/dist/meeting/index.js +98 -46
  13. package/dist/meeting/index.js.map +1 -1
  14. package/dist/metrics/constants.js +2 -1
  15. package/dist/metrics/constants.js.map +1 -1
  16. package/dist/metrics/index.js +57 -0
  17. package/dist/metrics/index.js.map +1 -1
  18. package/dist/reachability/clusterReachability.js +108 -53
  19. package/dist/reachability/clusterReachability.js.map +1 -1
  20. package/dist/reachability/index.js +415 -56
  21. package/dist/reachability/index.js.map +1 -1
  22. package/dist/statsAnalyzer/index.js +81 -27
  23. package/dist/statsAnalyzer/index.js.map +1 -1
  24. package/dist/statsAnalyzer/mqaUtil.js +36 -10
  25. package/dist/statsAnalyzer/mqaUtil.js.map +1 -1
  26. package/dist/types/media/MediaConnectionAwaiter.d.ts +18 -4
  27. package/dist/types/mediaQualityMetrics/config.d.ts +11 -0
  28. package/dist/types/meeting/connectionStateHandler.d.ts +30 -0
  29. package/dist/types/meeting/index.d.ts +2 -0
  30. package/dist/types/metrics/constants.d.ts +1 -0
  31. package/dist/types/metrics/index.d.ts +15 -0
  32. package/dist/types/reachability/clusterReachability.d.ts +31 -3
  33. package/dist/types/reachability/index.d.ts +93 -2
  34. package/dist/types/statsAnalyzer/index.d.ts +15 -6
  35. package/dist/types/statsAnalyzer/mqaUtil.d.ts +17 -4
  36. package/dist/webinar/index.js +1 -1
  37. package/package.json +23 -22
  38. package/src/breakouts/index.ts +7 -1
  39. package/src/media/MediaConnectionAwaiter.ts +66 -11
  40. package/src/mediaQualityMetrics/config.ts +14 -3
  41. package/src/meeting/connectionStateHandler.ts +65 -0
  42. package/src/meeting/index.ts +72 -14
  43. package/src/metrics/constants.ts +1 -0
  44. package/src/metrics/index.ts +44 -0
  45. package/src/reachability/clusterReachability.ts +86 -25
  46. package/src/reachability/index.ts +316 -27
  47. package/src/statsAnalyzer/index.ts +85 -24
  48. package/src/statsAnalyzer/mqaUtil.ts +55 -7
  49. package/test/unit/spec/breakouts/index.ts +51 -32
  50. package/test/unit/spec/media/MediaConnectionAwaiter.ts +90 -32
  51. package/test/unit/spec/meeting/connectionStateHandler.ts +102 -0
  52. package/test/unit/spec/meeting/index.js +158 -36
  53. package/test/unit/spec/metrics/index.js +126 -0
  54. package/test/unit/spec/reachability/clusterReachability.ts +116 -22
  55. package/test/unit/spec/reachability/index.ts +1153 -84
  56. package/test/unit/spec/stats-analyzer/index.js +647 -319
@@ -3,8 +3,9 @@
3
3
  */
4
4
 
5
5
  /* eslint-disable class-methods-use-this */
6
- import {mapValues} from 'lodash';
6
+ import {isEqual, mapValues, mean} from 'lodash';
7
7
 
8
+ import {Defer} from '@webex/common';
8
9
  import LoggerProxy from '../common/logs/logger-proxy';
9
10
  import MeetingUtil from '../meeting/util';
10
11
 
@@ -12,10 +13,16 @@ import {REACHABILITY} from '../constants';
12
13
 
13
14
  import ReachabilityRequest, {ClusterList} from './request';
14
15
  import {
16
+ ClientMediaIpsUpdatedEventData,
15
17
  ClusterReachability,
16
18
  ClusterReachabilityResult,
19
+ Events,
20
+ ResultEventData,
17
21
  TransportResult,
18
22
  } from './clusterReachability';
23
+ import EventsScope from '../common/events/events-scope';
24
+ import BEHAVIORAL_METRICS from '../metrics/constants';
25
+ import Metrics from '../metrics';
19
26
 
20
27
  export type ReachabilityMetrics = {
21
28
  reachability_public_udp_success: number;
@@ -60,11 +67,16 @@ export type ReachabilityResults = Record<
60
67
  }
61
68
  >;
62
69
 
70
+ // timeouts in seconds
71
+ const DEFAULT_TIMEOUT = 3;
72
+ const VIDEO_MESH_TIMEOUT = 1;
73
+ const OVERALL_TIMEOUT = 15;
74
+
63
75
  /**
64
76
  * @class Reachability
65
77
  * @export
66
78
  */
67
- export default class Reachability {
79
+ export default class Reachability extends EventsScope {
68
80
  namespace = REACHABILITY.namespace;
69
81
  webex: object;
70
82
  reachabilityRequest: ReachabilityRequest;
@@ -72,12 +84,22 @@ export default class Reachability {
72
84
  [key: string]: ClusterReachability;
73
85
  };
74
86
 
87
+ reachabilityDefer?: Defer;
88
+
89
+ vmnTimer?: ReturnType<typeof setTimeout>;
90
+ publicCloudTimer?: ReturnType<typeof setTimeout>;
91
+ overallTimer?: ReturnType<typeof setTimeout>;
92
+
93
+ expectedResultsCount = {videoMesh: {udp: 0}, public: {udp: 0, tcp: 0, xtls: 0}};
94
+ resultsCount = {videoMesh: {udp: 0}, public: {udp: 0, tcp: 0, xtls: 0}};
95
+
75
96
  /**
76
97
  * Creates an instance of Reachability.
77
98
  * @param {object} webex
78
99
  * @memberof Reachability
79
100
  */
80
101
  constructor(webex: object) {
102
+ super();
81
103
  this.webex = webex;
82
104
 
83
105
  /**
@@ -105,15 +127,6 @@ export default class Reachability {
105
127
  MeetingUtil.getIpVersion(this.webex)
106
128
  );
107
129
 
108
- // Perform Reachability Check
109
- const results = await this.performReachabilityChecks(clusters);
110
-
111
- // @ts-ignore
112
- await this.webex.boundedStorage.put(
113
- this.namespace,
114
- REACHABILITY.localStorageResult,
115
- JSON.stringify(results)
116
- );
117
130
  // @ts-ignore
118
131
  await this.webex.boundedStorage.put(
119
132
  this.namespace,
@@ -121,11 +134,12 @@ export default class Reachability {
121
134
  JSON.stringify(joinCookie)
122
135
  );
123
136
 
124
- LoggerProxy.logger.log(
125
- 'Reachability:index#gatherReachability --> Reachability checks completed'
126
- );
137
+ this.reachabilityDefer = new Defer();
138
+
139
+ // Perform Reachability Check
140
+ await this.performReachabilityChecks(clusters);
127
141
 
128
- return results;
142
+ return this.reachabilityDefer.promise;
129
143
  } catch (error) {
130
144
  LoggerProxy.logger.error(`Reachability:index#gatherReachability --> Error:`, error);
131
145
 
@@ -395,16 +409,210 @@ export default class Reachability {
395
409
  });
396
410
  }
397
411
 
412
+ /**
413
+ * Returns true if we've obtained all the reachability results for all the public clusters
414
+ * In other words, it means that all public clusters are reachable over each protocol,
415
+ * because we only get a "result" if we managed to reach a cluster
416
+ *
417
+ * @returns {boolean}
418
+ */
419
+ private areAllPublicClusterResultsReady() {
420
+ return isEqual(this.expectedResultsCount.public, this.resultsCount.public);
421
+ }
422
+
423
+ /**
424
+ * Returns true if we've obtained all the reachability results for all the clusters
425
+ *
426
+ * @returns {boolean}
427
+ */
428
+ private areAllResultsReady() {
429
+ return isEqual(this.expectedResultsCount, this.resultsCount);
430
+ }
431
+
432
+ /**
433
+ * Resolves the promise returned by gatherReachability() method
434
+ * @returns {void}
435
+ */
436
+ private resolveReachabilityPromise() {
437
+ if (this.vmnTimer) {
438
+ clearTimeout(this.vmnTimer);
439
+ }
440
+ if (this.publicCloudTimer) {
441
+ clearTimeout(this.publicCloudTimer);
442
+ }
443
+
444
+ this.logUnreachableClusters();
445
+ this.reachabilityDefer?.resolve();
446
+ }
447
+
448
+ /**
449
+ * Aborts all cluster reachability checks that are in progress
450
+ *
451
+ * @returns {void}
452
+ */
453
+ private abortClusterReachability() {
454
+ Object.values(this.clusterReachability).forEach((clusterReachability) => {
455
+ clusterReachability.abort();
456
+ });
457
+ }
458
+
459
+ /**
460
+ * Helper function for calculating min/max/average values of latency
461
+ *
462
+ * @param {Array<any>} results
463
+ * @param {string} protocol
464
+ * @param {boolean} isVideoMesh
465
+ * @returns {{min:number, max: number, average: number}}
466
+ */
467
+ protected getStatistics(
468
+ results: Array<ClusterReachabilityResult & {isVideoMesh: boolean}>,
469
+ protocol: 'udp' | 'tcp' | 'xtls',
470
+ isVideoMesh: boolean
471
+ ) {
472
+ const values = results
473
+ .filter((result) => result.isVideoMesh === isVideoMesh)
474
+ .filter((result) => result[protocol].result === 'reachable')
475
+ .map((result) => result[protocol].latencyInMilliseconds);
476
+
477
+ if (values.length === 0) {
478
+ return {
479
+ min: -1,
480
+ max: -1,
481
+ average: -1,
482
+ };
483
+ }
484
+
485
+ return {
486
+ min: Math.min(...values),
487
+ max: Math.max(...values),
488
+ average: mean(values),
489
+ };
490
+ }
491
+
492
+ /**
493
+ * Sends a metric with all the statistics about how long reachability took
494
+ *
495
+ * @returns {void}
496
+ */
497
+ protected async sendMetric() {
498
+ const results = [];
499
+
500
+ Object.values(this.clusterReachability).forEach((clusterReachability) => {
501
+ results.push({
502
+ ...clusterReachability.getResult(),
503
+ isVideoMesh: clusterReachability.isVideoMesh,
504
+ });
505
+ });
506
+
507
+ const stats = {
508
+ vmn: {
509
+ udp: this.getStatistics(results, 'udp', true),
510
+ },
511
+ public: {
512
+ udp: this.getStatistics(results, 'udp', false),
513
+ tcp: this.getStatistics(results, 'tcp', false),
514
+ xtls: this.getStatistics(results, 'xtls', false),
515
+ },
516
+ };
517
+ Metrics.sendBehavioralMetric(
518
+ BEHAVIORAL_METRICS.REACHABILITY_COMPLETED,
519
+ Metrics.prepareMetricFields(stats)
520
+ );
521
+ }
522
+
523
+ /**
524
+ * Starts all the timers used for various timeouts
525
+ *
526
+ * @returns {void}
527
+ */
528
+ private startTimers() {
529
+ this.vmnTimer = setTimeout(() => {
530
+ this.vmnTimer = undefined;
531
+ // if we are only missing VMN results, then we don't want to wait for them any longer
532
+ // as they are likely to fail if users are not on corporate network
533
+ if (this.areAllPublicClusterResultsReady()) {
534
+ LoggerProxy.logger.log(
535
+ 'Reachability:index#startTimers --> Reachability checks timed out (VMN timeout)'
536
+ );
537
+
538
+ this.resolveReachabilityPromise();
539
+ }
540
+ }, VIDEO_MESH_TIMEOUT * 1000);
541
+
542
+ this.publicCloudTimer = setTimeout(() => {
543
+ this.publicCloudTimer = undefined;
544
+
545
+ LoggerProxy.logger.log(
546
+ `Reachability:index#startTimers --> Reachability checks timed out (${DEFAULT_TIMEOUT}s)`
547
+ );
548
+
549
+ // resolve the promise, so that the client won't be blocked waiting on meetings.register() for too long
550
+ this.resolveReachabilityPromise();
551
+ }, DEFAULT_TIMEOUT * 1000);
552
+
553
+ this.overallTimer = setTimeout(() => {
554
+ this.overallTimer = undefined;
555
+ this.abortClusterReachability();
556
+ this.emit(
557
+ {
558
+ file: 'reachability',
559
+ function: 'overallTimer timeout',
560
+ },
561
+ 'reachability:done',
562
+ {}
563
+ );
564
+ this.sendMetric();
565
+
566
+ LoggerProxy.logger.log(
567
+ `Reachability:index#startTimers --> Reachability checks fully timed out (${OVERALL_TIMEOUT}s)`
568
+ );
569
+ }, OVERALL_TIMEOUT * 1000);
570
+ }
571
+
572
+ /**
573
+ * Stores given reachability results in local storage
574
+ *
575
+ * @param {ReachabilityResults} results
576
+ * @returns {Promise<void>}
577
+ */
578
+ private async storeResults(results: ReachabilityResults) {
579
+ // @ts-ignore
580
+ await this.webex.boundedStorage.put(
581
+ this.namespace,
582
+ REACHABILITY.localStorageResult,
583
+ JSON.stringify(results)
584
+ );
585
+ }
586
+
587
+ /**
588
+ * Resets all the internal counters that keep track of the results
589
+ *
590
+ * @returns {void}
591
+ */
592
+ private resetResultCounters() {
593
+ this.expectedResultsCount.videoMesh.udp = 0;
594
+ this.expectedResultsCount.public.udp = 0;
595
+ this.expectedResultsCount.public.tcp = 0;
596
+ this.expectedResultsCount.public.xtls = 0;
597
+
598
+ this.resultsCount.videoMesh.udp = 0;
599
+ this.resultsCount.public.udp = 0;
600
+ this.resultsCount.public.tcp = 0;
601
+ this.resultsCount.public.xtls = 0;
602
+ }
603
+
398
604
  /**
399
605
  * Performs reachability checks for all clusters
400
606
  * @param {ClusterList} clusterList
401
- * @returns {Promise<ReachabilityResults>} reachability check results
607
+ * @returns {Promise<void>} promise that's resolved as soon as the checks are started
402
608
  */
403
- private async performReachabilityChecks(clusterList: ClusterList): Promise<ReachabilityResults> {
609
+ private async performReachabilityChecks(clusterList: ClusterList) {
404
610
  const results: ReachabilityResults = {};
405
611
 
612
+ this.clusterReachability = {};
613
+
406
614
  if (!clusterList || !Object.keys(clusterList).length) {
407
- return Promise.resolve(results);
615
+ return;
408
616
  }
409
617
 
410
618
  LoggerProxy.logger.log(
@@ -417,7 +625,11 @@ export default class Reachability {
417
625
  } reachability checks`
418
626
  );
419
627
 
420
- const clusterReachabilityChecks = Object.keys(clusterList).map((key) => {
628
+ this.resetResultCounters();
629
+ this.startTimers();
630
+
631
+ // sanitize the urls in the clusterList
632
+ Object.keys(clusterList).forEach((key) => {
421
633
  const cluster = clusterList[key];
422
634
 
423
635
  // Linus doesn't support TCP reachability checks on video mesh nodes
@@ -429,6 +641,7 @@ export default class Reachability {
429
641
  cluster.tcp = [];
430
642
  }
431
643
 
644
+ // Linus doesn't support xTLS reachability checks on video mesh nodes
432
645
  const includeTlsReachability =
433
646
  // @ts-ignore
434
647
  this.webex.config.meetings.experimental.enableTlsReachability && !cluster.isVideoMesh;
@@ -437,18 +650,94 @@ export default class Reachability {
437
650
  cluster.xtls = [];
438
651
  }
439
652
 
440
- this.clusterReachability[key] = new ClusterReachability(key, cluster);
653
+ // initialize the result for this cluster
654
+ results[key] = {
655
+ udp: {result: cluster.udp.length > 0 ? 'unreachable' : 'untested'},
656
+ tcp: {result: cluster.tcp.length > 0 ? 'unreachable' : 'untested'},
657
+ xtls: {result: cluster.xtls.length > 0 ? 'unreachable' : 'untested'},
658
+ isVideoMesh: cluster.isVideoMesh,
659
+ };
660
+
661
+ // update expected results counters to include this cluster
662
+ this.expectedResultsCount[cluster.isVideoMesh ? 'videoMesh' : 'public'].udp +=
663
+ cluster.udp.length;
664
+ if (!cluster.isVideoMesh) {
665
+ this.expectedResultsCount.public.tcp += cluster.tcp.length;
666
+ this.expectedResultsCount.public.xtls += cluster.xtls.length;
667
+ }
668
+ });
669
+
670
+ const isFirstResult = {
671
+ udp: true,
672
+ tcp: true,
673
+ xtls: true,
674
+ };
675
+
676
+ // save the initialized results (in case we don't get any "resultReady" events at all)
677
+ await this.storeResults(results);
441
678
 
442
- return this.clusterReachability[key].start().then((result) => {
443
- results[key] = result;
444
- results[key].isVideoMesh = cluster.isVideoMesh;
679
+ // now start the reachability on all the clusters
680
+ Object.keys(clusterList).forEach((key) => {
681
+ const cluster = clusterList[key];
682
+
683
+ this.clusterReachability[key] = new ClusterReachability(key, cluster);
684
+ this.clusterReachability[key].on(Events.resultReady, async (data: ResultEventData) => {
685
+ const {protocol, result, clientMediaIPs, latencyInMilliseconds} = data;
686
+
687
+ if (isFirstResult[protocol]) {
688
+ this.emit(
689
+ {
690
+ file: 'reachability',
691
+ function: 'resultReady event handler',
692
+ },
693
+ 'reachability:firstResultAvailable',
694
+ {
695
+ protocol,
696
+ }
697
+ );
698
+ isFirstResult[protocol] = false;
699
+ }
700
+ this.resultsCount[cluster.isVideoMesh ? 'videoMesh' : 'public'][protocol] += 1;
701
+
702
+ const areAllResultsReady = this.areAllResultsReady();
703
+
704
+ results[key][protocol].result = result;
705
+ results[key][protocol].clientMediaIPs = clientMediaIPs;
706
+ results[key][protocol].latencyInMilliseconds = latencyInMilliseconds;
707
+
708
+ await this.storeResults(results);
709
+
710
+ if (areAllResultsReady) {
711
+ clearTimeout(this.overallTimer);
712
+ this.overallTimer = undefined;
713
+ this.emit(
714
+ {
715
+ file: 'reachability',
716
+ function: 'performReachabilityChecks',
717
+ },
718
+ 'reachability:done',
719
+ {}
720
+ );
721
+ this.sendMetric();
722
+
723
+ LoggerProxy.logger.log(
724
+ `Reachability:index#gatherReachability --> Reachability checks fully completed`
725
+ );
726
+ this.resolveReachabilityPromise();
727
+ }
445
728
  });
446
- });
447
729
 
448
- await Promise.all(clusterReachabilityChecks);
730
+ // clientMediaIps can be updated independently from the results, so we need to listen for them too
731
+ this.clusterReachability[key].on(
732
+ Events.clientMediaIpsUpdated,
733
+ async (data: ClientMediaIpsUpdatedEventData) => {
734
+ results[key][data.protocol].clientMediaIPs = data.clientMediaIPs;
449
735
 
450
- this.logUnreachableClusters();
736
+ await this.storeResults(results);
737
+ }
738
+ );
451
739
 
452
- return results;
740
+ this.clusterReachability[key].start(); // not awaiting on purpose
741
+ });
453
742
  }
454
743
  }