@webex/calling 3.12.0-mobius-socket.11 → 3.12.0-mobius-socket.13
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.
- package/dist/CallingClient/CallingClient.js +21 -30
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +1 -1
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/constants.js +15 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +1 -1
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +200 -116
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +1 -1
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/utils/mobiusSocketMapper.js +32 -20
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -1
- package/dist/CallingClient/utils/request.js +32 -3
- package/dist/CallingClient/utils/request.js.map +1 -1
- package/dist/CallingClient/utils/wsFeatureFlag.js +9 -1
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -1
- package/dist/common/Utils.js +70 -30
- package/dist/common/Utils.js.map +1 -1
- package/dist/module/CallingClient/CallingClient.js +13 -18
- package/dist/module/CallingClient/constants.js +12 -0
- package/dist/module/CallingClient/registration/register.js +101 -40
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +11 -0
- package/dist/module/CallingClient/utils/request.js +29 -1
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +9 -2
- package/dist/module/common/Utils.js +17 -4
- package/dist/types/CallingClient/CallingClient.d.ts +0 -1
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +12 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +1 -1
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +4 -1
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -317,25 +317,44 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
317
317
|
value: (function () {
|
|
318
318
|
var _restorePreviousRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(caller) {
|
|
319
319
|
var _this = this;
|
|
320
|
-
var abort;
|
|
320
|
+
var loggerContext, abort;
|
|
321
321
|
return _regenerator.default.wrap(function (_context5) {
|
|
322
322
|
while (1) switch (_context5.prev = _context5.next) {
|
|
323
323
|
case 0:
|
|
324
|
+
loggerContext = {
|
|
325
|
+
file: _constants2.REGISTRATION_FILE,
|
|
326
|
+
method: _constants2.METHODS.RESTORE_PREVIOUS_REGISTRATION
|
|
327
|
+
};
|
|
328
|
+
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " - caller: ").concat(caller, ", activeMobiusUrl: ").concat(this.activeMobiusUrl), loggerContext);
|
|
324
329
|
abort = false;
|
|
325
|
-
if (!this.
|
|
326
|
-
_context5.next =
|
|
330
|
+
if (!this.apiRequest.isSocketEnabled()) {
|
|
331
|
+
_context5.next = 1;
|
|
327
332
|
break;
|
|
328
333
|
}
|
|
334
|
+
_Logger.default.info("Disconnecting from Mobius socket to restore previous registration.", {
|
|
335
|
+
file: _constants2.REGISTRATION_FILE,
|
|
336
|
+
method: 'restorePreviousRegistration'
|
|
337
|
+
});
|
|
329
338
|
_context5.next = 1;
|
|
330
|
-
return this.
|
|
339
|
+
return this.apiRequest.disconnectFromMobiusSocket({
|
|
340
|
+
code: 3050,
|
|
341
|
+
reason: 'done (permanent)'
|
|
342
|
+
});
|
|
331
343
|
case 1:
|
|
344
|
+
if (!this.activeMobiusUrl) {
|
|
345
|
+
_context5.next = 7;
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
_context5.next = 2;
|
|
349
|
+
return this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
|
|
350
|
+
case 2:
|
|
332
351
|
abort = _context5.sent;
|
|
333
352
|
if (!this.retryAfter) {
|
|
334
|
-
_context5.next =
|
|
353
|
+
_context5.next = 7;
|
|
335
354
|
break;
|
|
336
355
|
}
|
|
337
356
|
if (!(this.retryAfter < _constants2.RETRY_TIMER_UPPER_LIMIT)) {
|
|
338
|
-
_context5.next =
|
|
357
|
+
_context5.next = 3;
|
|
339
358
|
break;
|
|
340
359
|
}
|
|
341
360
|
// If retry-after is less than threshold, honor it and schedule retry
|
|
@@ -351,28 +370,30 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
351
370
|
}
|
|
352
371
|
}, _callee4);
|
|
353
372
|
})), this.retryAfter * 1000);
|
|
354
|
-
_context5.next =
|
|
373
|
+
_context5.next = 6;
|
|
355
374
|
break;
|
|
356
|
-
case
|
|
375
|
+
case 3:
|
|
357
376
|
if (!(this.primaryMobiusUris.includes(this.activeMobiusUrl) && this.backupMobiusUris.length > 0)) {
|
|
358
|
-
_context5.next =
|
|
377
|
+
_context5.next = 5;
|
|
359
378
|
break;
|
|
360
379
|
}
|
|
361
|
-
_context5.next =
|
|
380
|
+
_context5.next = 4;
|
|
362
381
|
return this.attemptRegistrationWithServers(caller, this.backupMobiusUris);
|
|
363
|
-
case
|
|
382
|
+
case 4:
|
|
364
383
|
abort = _context5.sent;
|
|
365
|
-
_context5.next =
|
|
384
|
+
_context5.next = 6;
|
|
366
385
|
break;
|
|
367
|
-
case 4:
|
|
368
|
-
// If we are using backup and got 429, restart registration
|
|
369
|
-
this.restartRegistration(caller);
|
|
370
386
|
case 5:
|
|
387
|
+
_context5.next = 6;
|
|
388
|
+
return this.restartRegistration(caller);
|
|
389
|
+
case 6:
|
|
371
390
|
this.retryAfter = undefined;
|
|
391
|
+
_Logger.default.log("restorePreviousRegistration completed via 429 retry-after path - caller: ".concat(caller), loggerContext);
|
|
372
392
|
return _context5.abrupt("return", true);
|
|
373
|
-
case 6:
|
|
374
|
-
return _context5.abrupt("return", abort);
|
|
375
393
|
case 7:
|
|
394
|
+
_Logger.default.log("restorePreviousRegistration completed - caller: ".concat(caller, ", deviceRegistered: ").concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
|
|
395
|
+
return _context5.abrupt("return", abort);
|
|
396
|
+
case 8:
|
|
376
397
|
case "end":
|
|
377
398
|
return _context5.stop();
|
|
378
399
|
}
|
|
@@ -391,12 +412,17 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
391
412
|
key: "handle404KeepaliveFailure",
|
|
392
413
|
value: (function () {
|
|
393
414
|
var _handle404KeepaliveFailure = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6(caller) {
|
|
394
|
-
var abort;
|
|
415
|
+
var loggerContext, abort;
|
|
395
416
|
return _regenerator.default.wrap(function (_context6) {
|
|
396
417
|
while (1) switch (_context6.prev = _context6.next) {
|
|
397
418
|
case 0:
|
|
419
|
+
loggerContext = {
|
|
420
|
+
file: _constants2.REGISTRATION_FILE,
|
|
421
|
+
method: _constants2.METHODS.HANDLE_404_KEEPALIVE_FAILURE
|
|
422
|
+
};
|
|
423
|
+
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " - caller: ").concat(caller), loggerContext);
|
|
398
424
|
if (!(caller === _constants2.KEEPALIVE_UTIL)) {
|
|
399
|
-
_context6.next =
|
|
425
|
+
_context6.next = 4;
|
|
400
426
|
break;
|
|
401
427
|
}
|
|
402
428
|
_context6.next = 1;
|
|
@@ -404,12 +430,18 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
404
430
|
case 1:
|
|
405
431
|
abort = _context6.sent;
|
|
406
432
|
if (!(!abort && !this.isDeviceRegistered())) {
|
|
407
|
-
_context6.next =
|
|
433
|
+
_context6.next = 3;
|
|
408
434
|
break;
|
|
409
435
|
}
|
|
436
|
+
_Logger.default.warn('Keepalive 404 recovery: re-registration did not complete, starting failover timer', loggerContext);
|
|
410
437
|
_context6.next = 2;
|
|
411
438
|
return this.startFailoverTimer();
|
|
412
439
|
case 2:
|
|
440
|
+
_context6.next = 4;
|
|
441
|
+
break;
|
|
442
|
+
case 3:
|
|
443
|
+
_Logger.default.log("Keepalive 404 recovery handled - deviceRegistered: ".concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
|
|
444
|
+
case 4:
|
|
413
445
|
case "end":
|
|
414
446
|
return _context6.stop();
|
|
415
447
|
}
|
|
@@ -602,13 +634,26 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
602
634
|
}, _callee0);
|
|
603
635
|
})), interval * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
604
636
|
_Logger.default.log("Scheduled retry with primary in ".concat(interval, " seconds, number of attempts : ").concat(attempt), loggerContext);
|
|
605
|
-
_context11.next =
|
|
637
|
+
_context11.next = 7;
|
|
606
638
|
break;
|
|
607
639
|
case 1:
|
|
608
640
|
if (!this.backupMobiusUris.length) {
|
|
641
|
+
_context11.next = 5;
|
|
642
|
+
break;
|
|
643
|
+
}
|
|
644
|
+
if (!this.apiRequest.isSocketEnabled()) {
|
|
609
645
|
_context11.next = 3;
|
|
610
646
|
break;
|
|
611
647
|
}
|
|
648
|
+
_Logger.default.info('Disconnecting from primary Mobius socket for failover to backup servers', loggerContext);
|
|
649
|
+
_context11.next = 2;
|
|
650
|
+
return this.apiRequest.disconnectFromMobiusSocket({
|
|
651
|
+
code: 3050,
|
|
652
|
+
reason: 'done (permanent)'
|
|
653
|
+
});
|
|
654
|
+
case 2:
|
|
655
|
+
_Logger.default.log('Mobius socket disconnect complete prior to backup failover', loggerContext);
|
|
656
|
+
case 3:
|
|
612
657
|
this.saveFailoverState({
|
|
613
658
|
attempt: attempt,
|
|
614
659
|
timeElapsed: timeElapsed,
|
|
@@ -617,9 +662,9 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
617
662
|
});
|
|
618
663
|
_Logger.default.info('Failing over to backup servers.', loggerContext);
|
|
619
664
|
this.failoverImmediately = false;
|
|
620
|
-
_context11.next =
|
|
665
|
+
_context11.next = 4;
|
|
621
666
|
return this.attemptRegistrationWithServers(_constants2.FAILOVER_UTIL, this.backupMobiusUris);
|
|
622
|
-
case
|
|
667
|
+
case 4:
|
|
623
668
|
abort = _context11.sent;
|
|
624
669
|
if (!abort && !this.isDeviceRegistered()) {
|
|
625
670
|
interval = this.getRegRetryInterval();
|
|
@@ -663,16 +708,16 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
663
708
|
})), interval * _constants2.SEC_TO_MSEC_MFACTOR);
|
|
664
709
|
_Logger.default.log("Scheduled retry with backup servers in ".concat(interval, " seconds."), loggerContext);
|
|
665
710
|
}
|
|
666
|
-
_context11.next =
|
|
711
|
+
_context11.next = 7;
|
|
667
712
|
break;
|
|
668
|
-
case
|
|
669
|
-
_context11.next =
|
|
713
|
+
case 5:
|
|
714
|
+
_context11.next = 6;
|
|
670
715
|
return (0, _common.uploadLogs)();
|
|
671
|
-
case
|
|
716
|
+
case 6:
|
|
672
717
|
(0, _common.emitFinalFailure)(function (clientError) {
|
|
673
718
|
_this3.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
674
719
|
}, loggerContext, interval < 0 ? 'Timer threshold exceeded during failover' : undefined);
|
|
675
|
-
case
|
|
720
|
+
case 7:
|
|
676
721
|
case "end":
|
|
677
722
|
return _context11.stop();
|
|
678
723
|
}
|
|
@@ -826,13 +871,21 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
826
871
|
}, {
|
|
827
872
|
key: "initiateFailback",
|
|
828
873
|
value: function initiateFailback() {
|
|
874
|
+
var loggerContext = {
|
|
875
|
+
file: _constants2.REGISTRATION_FILE,
|
|
876
|
+
method: _constants2.METHODS.INITIATE_FAILBACK
|
|
877
|
+
};
|
|
829
878
|
if (this.isFailbackRequired()) {
|
|
830
879
|
if (!this.failbackTimer) {
|
|
831
880
|
this.failback429RetryAttempts = 0;
|
|
832
881
|
var intervalInMinutes = this.getFailbackInterval();
|
|
882
|
+
_Logger.default.info("Scheduling failback to primary - intervalMinutes: ".concat(intervalInMinutes), loggerContext);
|
|
833
883
|
this.startFailbackTimer(intervalInMinutes * _constants2.MINUTES_TO_SEC_MFACTOR);
|
|
884
|
+
} else {
|
|
885
|
+
_Logger.default.info('Failback timer already scheduled, skipping', loggerContext);
|
|
834
886
|
}
|
|
835
887
|
} else {
|
|
888
|
+
_Logger.default.info('Failback not required, clearing any pending failback timer', loggerContext);
|
|
836
889
|
this.failback429RetryAttempts = 0;
|
|
837
890
|
this.clearFailbackTimer();
|
|
838
891
|
}
|
|
@@ -872,9 +925,15 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
872
925
|
value: (function () {
|
|
873
926
|
var _executeFailback = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
874
927
|
var _this5 = this;
|
|
928
|
+
var loggerContext;
|
|
875
929
|
return _regenerator.default.wrap(function (_context16) {
|
|
876
930
|
while (1) switch (_context16.prev = _context16.next) {
|
|
877
931
|
case 0:
|
|
932
|
+
loggerContext = {
|
|
933
|
+
file: _constants2.REGISTRATION_FILE,
|
|
934
|
+
method: _constants2.METHODS.EXECUTE_FAILBACK
|
|
935
|
+
};
|
|
936
|
+
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
878
937
|
_context16.next = 1;
|
|
879
938
|
return this.mutex.runExclusive(/*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
|
|
880
939
|
var primaryServerStatus, abort, abortNew;
|
|
@@ -882,7 +941,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
882
941
|
while (1) switch (_context15.prev = _context15.next) {
|
|
883
942
|
case 0:
|
|
884
943
|
if (!_this5.isFailbackRequired()) {
|
|
885
|
-
_context15.next =
|
|
944
|
+
_context15.next = 13;
|
|
886
945
|
break;
|
|
887
946
|
}
|
|
888
947
|
_context15.next = 1;
|
|
@@ -890,70 +949,67 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
890
949
|
case 1:
|
|
891
950
|
primaryServerStatus = _context15.sent;
|
|
892
951
|
if (!((0, _keys.default)(_this5.callManager.getActiveCalls()).length === 0 && primaryServerStatus)) {
|
|
893
|
-
_context15.next =
|
|
952
|
+
_context15.next = 12;
|
|
894
953
|
break;
|
|
895
954
|
}
|
|
896
|
-
_Logger.default.info("Attempting failback to primary.",
|
|
897
|
-
file: _constants2.REGISTRATION_FILE,
|
|
898
|
-
method: _this5.executeFailback.name
|
|
899
|
-
});
|
|
955
|
+
_Logger.default.info("Attempting failback to primary.", loggerContext);
|
|
900
956
|
_context15.next = 2;
|
|
901
957
|
return _this5.deregister();
|
|
902
958
|
case 2:
|
|
903
959
|
if (!_this5.apiRequest.isSocketEnabled()) {
|
|
904
|
-
_context15.next =
|
|
960
|
+
_context15.next = 4;
|
|
905
961
|
break;
|
|
906
962
|
}
|
|
963
|
+
_Logger.default.info('Disconnecting from backup Mobius socket for failback to primary', loggerContext);
|
|
907
964
|
_context15.next = 3;
|
|
908
965
|
return _this5.apiRequest.disconnectFromMobiusSocket({
|
|
909
966
|
code: 3050,
|
|
910
967
|
reason: 'done (permanent)'
|
|
911
968
|
});
|
|
912
969
|
case 3:
|
|
913
|
-
|
|
914
|
-
return _this5.attemptRegistrationWithServers(_constants2.FAILBACK_UTIL);
|
|
970
|
+
_Logger.default.log('Mobius socket disconnect complete prior to primary failback', loggerContext);
|
|
915
971
|
case 4:
|
|
972
|
+
_context15.next = 5;
|
|
973
|
+
return _this5.attemptRegistrationWithServers(_constants2.FAILBACK_UTIL);
|
|
974
|
+
case 5:
|
|
916
975
|
abort = _context15.sent;
|
|
917
976
|
if (!(_this5.scheduled429Retry || abort || _this5.isDeviceRegistered())) {
|
|
918
|
-
_context15.next =
|
|
977
|
+
_context15.next = 6;
|
|
919
978
|
break;
|
|
920
979
|
}
|
|
921
980
|
return _context15.abrupt("return");
|
|
922
|
-
case 5:
|
|
923
|
-
_context15.next = 6;
|
|
924
|
-
return _this5.restorePreviousRegistration(_constants2.FAILBACK_UTIL);
|
|
925
981
|
case 6:
|
|
982
|
+
_context15.next = 7;
|
|
983
|
+
return _this5.restorePreviousRegistration(_constants2.FAILBACK_UTIL);
|
|
984
|
+
case 7:
|
|
926
985
|
abortNew = _context15.sent;
|
|
927
986
|
if (!abortNew) {
|
|
928
|
-
_context15.next =
|
|
987
|
+
_context15.next = 8;
|
|
929
988
|
break;
|
|
930
989
|
}
|
|
931
990
|
_this5.clearFailbackTimer();
|
|
932
991
|
return _context15.abrupt("return");
|
|
933
|
-
case
|
|
992
|
+
case 8:
|
|
934
993
|
if (_this5.isDeviceRegistered()) {
|
|
935
|
-
_context15.next =
|
|
994
|
+
_context15.next = 10;
|
|
936
995
|
break;
|
|
937
996
|
}
|
|
938
|
-
_context15.next =
|
|
939
|
-
return _this5.restartRegistration(
|
|
940
|
-
case 8:
|
|
941
|
-
_context15.next = 10;
|
|
942
|
-
break;
|
|
997
|
+
_context15.next = 9;
|
|
998
|
+
return _this5.restartRegistration(loggerContext.method);
|
|
943
999
|
case 9:
|
|
1000
|
+
_context15.next = 11;
|
|
1001
|
+
break;
|
|
1002
|
+
case 10:
|
|
944
1003
|
_this5.failbackTimer = undefined;
|
|
945
1004
|
_this5.initiateFailback();
|
|
946
|
-
case 10:
|
|
947
|
-
_context15.next = 12;
|
|
948
|
-
break;
|
|
949
1005
|
case 11:
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
1006
|
+
_context15.next = 13;
|
|
1007
|
+
break;
|
|
1008
|
+
case 12:
|
|
1009
|
+
_Logger.default.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', loggerContext);
|
|
954
1010
|
_this5.failbackTimer = undefined;
|
|
955
1011
|
_this5.initiateFailback();
|
|
956
|
-
case
|
|
1012
|
+
case 13:
|
|
957
1013
|
case "end":
|
|
958
1014
|
return _context15.stop();
|
|
959
1015
|
}
|
|
@@ -1027,10 +1083,16 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1027
1083
|
key: "restartRegistration",
|
|
1028
1084
|
value: (function () {
|
|
1029
1085
|
var _restartRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17(caller) {
|
|
1030
|
-
var abort;
|
|
1086
|
+
var loggerContext, abort;
|
|
1031
1087
|
return _regenerator.default.wrap(function (_context17) {
|
|
1032
1088
|
while (1) switch (_context17.prev = _context17.next) {
|
|
1033
1089
|
case 0:
|
|
1090
|
+
loggerContext = {
|
|
1091
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1092
|
+
method: _constants2.METHODS.RESTART_REGISTRATION
|
|
1093
|
+
};
|
|
1094
|
+
_Logger.default.info("".concat(_constants.METHOD_START_MESSAGE, " - caller: ").concat(caller), loggerContext);
|
|
1095
|
+
|
|
1034
1096
|
/*
|
|
1035
1097
|
* Cancel any failback timer running
|
|
1036
1098
|
* and start fresh registration attempt with retry as true.
|
|
@@ -1048,6 +1110,8 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1048
1110
|
_context17.next = 2;
|
|
1049
1111
|
return this.startFailoverTimer();
|
|
1050
1112
|
case 2:
|
|
1113
|
+
_Logger.default.log("restartRegistration completed - caller: ".concat(caller, ", deviceRegistered: ").concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
|
|
1114
|
+
case 3:
|
|
1051
1115
|
case "end":
|
|
1052
1116
|
return _context17.stop();
|
|
1053
1117
|
}
|
|
@@ -1204,10 +1268,15 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1204
1268
|
key: "triggerRegistration",
|
|
1205
1269
|
value: (function () {
|
|
1206
1270
|
var _triggerRegistration = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
1207
|
-
var abort;
|
|
1271
|
+
var loggerContext, abort;
|
|
1208
1272
|
return _regenerator.default.wrap(function (_context21) {
|
|
1209
1273
|
while (1) switch (_context21.prev = _context21.next) {
|
|
1210
1274
|
case 0:
|
|
1275
|
+
loggerContext = {
|
|
1276
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1277
|
+
method: _constants2.METHODS.TRIGGER_REGISTRATION
|
|
1278
|
+
};
|
|
1279
|
+
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
1211
1280
|
_context21.next = 1;
|
|
1212
1281
|
return this.resumeFailover();
|
|
1213
1282
|
case 1:
|
|
@@ -1215,10 +1284,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1215
1284
|
_context21.next = 2;
|
|
1216
1285
|
break;
|
|
1217
1286
|
}
|
|
1287
|
+
_Logger.default.info('Registration trigger handled by resumeFailover path', loggerContext);
|
|
1218
1288
|
return _context21.abrupt("return");
|
|
1219
1289
|
case 2:
|
|
1220
1290
|
if (!(this.primaryMobiusUris.length > 0)) {
|
|
1221
|
-
_context21.next =
|
|
1291
|
+
_context21.next = 5;
|
|
1222
1292
|
break;
|
|
1223
1293
|
}
|
|
1224
1294
|
_context21.next = 3;
|
|
@@ -1232,6 +1302,12 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1232
1302
|
_context21.next = 4;
|
|
1233
1303
|
return this.startFailoverTimer();
|
|
1234
1304
|
case 4:
|
|
1305
|
+
_Logger.default.log("triggerRegistration completed - deviceRegistered: ".concat(this.isDeviceRegistered(), ", abort: ").concat(abort), loggerContext);
|
|
1306
|
+
_context21.next = 6;
|
|
1307
|
+
break;
|
|
1308
|
+
case 5:
|
|
1309
|
+
_Logger.default.warn('triggerRegistration skipped: no primary Mobius URIs available', loggerContext);
|
|
1310
|
+
case 6:
|
|
1235
1311
|
case "end":
|
|
1236
1312
|
return _context21.stop();
|
|
1237
1313
|
}
|
|
@@ -1257,6 +1333,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1257
1333
|
var _attemptRegistrationWithServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22(caller) {
|
|
1258
1334
|
var _this8 = this;
|
|
1259
1335
|
var servers,
|
|
1336
|
+
loggerContext,
|
|
1260
1337
|
abort,
|
|
1261
1338
|
connectedWebSocketUrl,
|
|
1262
1339
|
_iterator2,
|
|
@@ -1269,6 +1346,10 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1269
1346
|
while (1) switch (_context23.prev = _context23.next) {
|
|
1270
1347
|
case 0:
|
|
1271
1348
|
servers = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : this.primaryMobiusUris;
|
|
1349
|
+
loggerContext = {
|
|
1350
|
+
file: _constants2.REGISTRATION_FILE,
|
|
1351
|
+
method: _constants2.REGISTER_UTIL
|
|
1352
|
+
};
|
|
1272
1353
|
abort = false;
|
|
1273
1354
|
this.retryAfter = undefined;
|
|
1274
1355
|
if (!this.failoverImmediately) {
|
|
@@ -1281,17 +1362,14 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1281
1362
|
_context23.next = 2;
|
|
1282
1363
|
break;
|
|
1283
1364
|
}
|
|
1284
|
-
_Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl),
|
|
1285
|
-
file: _constants2.REGISTRATION_FILE,
|
|
1286
|
-
method: _constants2.REGISTER_UTIL
|
|
1287
|
-
});
|
|
1365
|
+
_Logger.default.info("[".concat(caller, "] : Device already registered with : ").concat(this.activeMobiusUrl), loggerContext);
|
|
1288
1366
|
return _context23.abrupt("return", abort);
|
|
1289
1367
|
case 2:
|
|
1290
1368
|
_iterator2 = _createForOfIteratorHelper(servers);
|
|
1291
1369
|
_context23.prev = 3;
|
|
1292
1370
|
_loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
|
|
1293
1371
|
var _this8$backupMobiusUr;
|
|
1294
|
-
var url, serverType, _this8$deviceInfo$dev, _resp$headers, _resp$headers$trackin, _resp$headers2, _this8$deviceInfo$dev2, wssNormalizedUrl, resp, body, _t5;
|
|
1372
|
+
var url, serverType, _this8$deviceInfo$dev, _resp$headers, _resp$headers$trackin, _resp$headers2, _this8$deviceInfo$dev2, wssNormalizedUrl, resp, body, _yield$handleRegistra, finalError, shouldDisconnect, _t5;
|
|
1295
1373
|
return _regenerator.default.wrap(function (_context22) {
|
|
1296
1374
|
while (1) switch (_context22.prev = _context22.next) {
|
|
1297
1375
|
case 0:
|
|
@@ -1301,20 +1379,21 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1301
1379
|
abort = false;
|
|
1302
1380
|
_this8.registrationStatus = _types2.RegistrationStatus.INACTIVE;
|
|
1303
1381
|
_this8.lineEmitter(_types3.LINE_EVENTS.CONNECTING);
|
|
1304
|
-
_Logger.default.info("[".concat(caller, "] : Mobius url to contact: ").concat(url),
|
|
1305
|
-
file: _constants2.REGISTRATION_FILE,
|
|
1306
|
-
method: _constants2.REGISTER_UTIL
|
|
1307
|
-
});
|
|
1382
|
+
_Logger.default.info("[".concat(caller, "] : Mobius url to contact: ").concat(url), loggerContext);
|
|
1308
1383
|
if (!_this8.apiRequest.isSocketEnabled()) {
|
|
1309
1384
|
_context22.next = 3;
|
|
1310
1385
|
break;
|
|
1311
1386
|
}
|
|
1312
|
-
wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
1387
|
+
wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
1388
|
+
_Logger.default.info("[".concat(caller, "] : Connecting to Mobius WebSocket - serverType: ").concat(serverType, ", wssUrl: ").concat(wssNormalizedUrl), loggerContext);
|
|
1389
|
+
|
|
1390
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1313
1391
|
_context22.next = 2;
|
|
1314
1392
|
return _this8.apiRequest.connectToMobiusSocket(wssNormalizedUrl);
|
|
1315
1393
|
case 2:
|
|
1316
1394
|
connectedWebSocketUrl = _context22.sent;
|
|
1317
1395
|
connectedWebSocketUrl = connectedWebSocketUrl ? "".concat(connectedWebSocketUrl, "/") : undefined;
|
|
1396
|
+
_Logger.default.log("[".concat(caller, "] : Mobius WebSocket connected - serverType: ").concat(serverType, ", connectedWebSocketUrl: ").concat(connectedWebSocketUrl), loggerContext);
|
|
1318
1397
|
case 3:
|
|
1319
1398
|
_context22.next = 4;
|
|
1320
1399
|
return _this8.postRegistration(url);
|
|
@@ -1325,10 +1404,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1325
1404
|
_this8.registrationStatus = _types2.RegistrationStatus.ACTIVE;
|
|
1326
1405
|
_this8.setActiveMobiusUrl(connectedWebSocketUrl || url);
|
|
1327
1406
|
_this8.lineEmitter(_types3.LINE_EVENTS.REGISTERED, resp.body);
|
|
1328
|
-
_Logger.default.log("Registration successful for deviceId: ".concat((_this8$deviceInfo$dev = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev === void 0 ? void 0 : _this8$deviceInfo$dev.deviceId, " userId: ").concat(_this8.userId, " responseTrackingId: ").concat((_resp$headers = resp.headers) === null || _resp$headers === void 0 ? void 0 : _resp$headers.trackingid),
|
|
1329
|
-
file: _constants2.REGISTRATION_FILE,
|
|
1330
|
-
method: _constants2.METHODS.REGISTER
|
|
1331
|
-
});
|
|
1407
|
+
_Logger.default.log("Registration successful for deviceId: ".concat((_this8$deviceInfo$dev = _this8.deviceInfo.device) === null || _this8$deviceInfo$dev === void 0 ? void 0 : _this8$deviceInfo$dev.deviceId, " userId: ").concat(_this8.userId, " responseTrackingId: ").concat((_resp$headers = resp.headers) === null || _resp$headers === void 0 ? void 0 : _resp$headers.trackingid), loggerContext);
|
|
1332
1408
|
_this8.setIntervalValues(_this8.deviceInfo);
|
|
1333
1409
|
_this8.metricManager.setDeviceInfo(_this8.deviceInfo);
|
|
1334
1410
|
_this8.metricManager.submitRegistrationMetric(_types.METRIC_EVENT.REGISTRATION, _types.REG_ACTION.REGISTER, _types.METRIC_TYPE.BEHAVIORAL, caller, serverType, (_resp$headers$trackin = (_resp$headers2 = resp.headers) === null || _resp$headers2 === void 0 ? void 0 : _resp$headers2.trackingid) !== null && _resp$headers$trackin !== void 0 ? _resp$headers$trackin : '', undefined, undefined);
|
|
@@ -1338,19 +1414,11 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1338
1414
|
case 5:
|
|
1339
1415
|
_context22.prev = 5;
|
|
1340
1416
|
_t5 = _context22["catch"](1);
|
|
1341
|
-
connectedWebSocketUrl = undefined;
|
|
1342
|
-
// eslint-disable-next-line no-await-in-loop
|
|
1343
|
-
_context22.next = 6;
|
|
1344
|
-
return _this8.apiRequest.disconnectFromMobiusSocket({
|
|
1345
|
-
code: 3050,
|
|
1346
|
-
reason: 'done (permanent)'
|
|
1347
|
-
});
|
|
1348
|
-
case 6:
|
|
1349
1417
|
body = _t5; // eslint-disable-next-line no-await-in-loop, @typescript-eslint/no-unused-vars
|
|
1350
|
-
_context22.next =
|
|
1351
|
-
return (0, _common.handleRegistrationErrors)(body, function (clientError,
|
|
1418
|
+
_context22.next = 6;
|
|
1419
|
+
return (0, _common.handleRegistrationErrors)(body, function (clientError, isFinalError) {
|
|
1352
1420
|
var _body$headers$trackin, _body$headers;
|
|
1353
|
-
if (
|
|
1421
|
+
if (isFinalError) {
|
|
1354
1422
|
_this8.lineEmitter(_types3.LINE_EVENTS.ERROR, undefined, clientError);
|
|
1355
1423
|
} else {
|
|
1356
1424
|
_this8.lineEmitter(_types3.LINE_EVENTS.UNREGISTERED);
|
|
@@ -1361,30 +1429,46 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1361
1429
|
file: _constants2.REGISTRATION_FILE
|
|
1362
1430
|
}, function (retryAfter, retryCaller) {
|
|
1363
1431
|
return _this8.handle429Retry(retryAfter, retryCaller);
|
|
1364
|
-
}, _this8.restoreRegistrationCallBack());
|
|
1365
|
-
case
|
|
1366
|
-
|
|
1432
|
+
}, _this8.restoreRegistrationCallBack(), servers.length);
|
|
1433
|
+
case 6:
|
|
1434
|
+
_yield$handleRegistra = _context22.sent;
|
|
1435
|
+
finalError = _yield$handleRegistra.finalError;
|
|
1436
|
+
shouldDisconnect = _yield$handleRegistra.shouldDisconnect;
|
|
1437
|
+
abort = finalError;
|
|
1367
1438
|
if (!(_this8.registrationStatus === _types2.RegistrationStatus.ACTIVE)) {
|
|
1368
|
-
_context22.next =
|
|
1439
|
+
_context22.next = 7;
|
|
1369
1440
|
break;
|
|
1370
1441
|
}
|
|
1371
|
-
_Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(_this8.activeMobiusUrl),
|
|
1372
|
-
file: _constants2.REGISTRATION_FILE,
|
|
1373
|
-
method: _this8.attemptRegistrationWithServers.name
|
|
1374
|
-
});
|
|
1442
|
+
_Logger.default.info("[".concat(caller, "] : Device is already restored, active mobius url: ").concat(_this8.activeMobiusUrl), loggerContext);
|
|
1375
1443
|
return _context22.abrupt("return", 0);
|
|
1444
|
+
case 7:
|
|
1445
|
+
if (!(shouldDisconnect && _this8.apiRequest.isSocketEnabled())) {
|
|
1446
|
+
_context22.next = 9;
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
connectedWebSocketUrl = undefined;
|
|
1450
|
+
_Logger.default.info("[".concat(caller, "] : Tearing down Mobius WebSocket after registration error - serverType: ").concat(serverType), loggerContext);
|
|
1451
|
+
|
|
1452
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1453
|
+
_context22.next = 8;
|
|
1454
|
+
return _this8.apiRequest.disconnectFromMobiusSocket({
|
|
1455
|
+
code: 3050,
|
|
1456
|
+
reason: 'done (permanent)'
|
|
1457
|
+
});
|
|
1376
1458
|
case 8:
|
|
1459
|
+
_Logger.default.log("[".concat(caller, "] : Mobius WebSocket disconnect complete after registration error - serverType: ").concat(serverType), loggerContext);
|
|
1460
|
+
case 9:
|
|
1377
1461
|
if (!abort) {
|
|
1378
|
-
_context22.next =
|
|
1462
|
+
_context22.next = 11;
|
|
1379
1463
|
break;
|
|
1380
1464
|
}
|
|
1381
1465
|
_this8.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1382
1466
|
// eslint-disable-next-line no-await-in-loop
|
|
1383
|
-
_context22.next =
|
|
1467
|
+
_context22.next = 10;
|
|
1384
1468
|
return (0, _common.uploadLogs)();
|
|
1385
|
-
case 9:
|
|
1386
|
-
return _context22.abrupt("return", 0);
|
|
1387
1469
|
case 10:
|
|
1470
|
+
return _context22.abrupt("return", 0);
|
|
1471
|
+
case 11:
|
|
1388
1472
|
case "end":
|
|
1389
1473
|
return _context22.stop();
|
|
1390
1474
|
}
|
|
@@ -1468,7 +1552,7 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1468
1552
|
});
|
|
1469
1553
|
_this9.webWorker.onmessage = /*#__PURE__*/function () {
|
|
1470
1554
|
var _ref11 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23(event) {
|
|
1471
|
-
var logContext, _this9$webWorker, res, _err$headers, _this9$webWorker2, error, _error, abort, _t7;
|
|
1555
|
+
var logContext, _this9$webWorker, res, _err$headers, _this9$webWorker2, error, _error, _yield$handleRegistra2, abort, _t7;
|
|
1472
1556
|
return _regenerator.default.wrap(function (_context24) {
|
|
1473
1557
|
while (1) switch (_context24.prev = _context24.next) {
|
|
1474
1558
|
case 0:
|
|
@@ -1532,7 +1616,8 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1532
1616
|
return _this9.handle429Retry(retryAfter, retryCaller);
|
|
1533
1617
|
});
|
|
1534
1618
|
case 5:
|
|
1535
|
-
|
|
1619
|
+
_yield$handleRegistra2 = _context24.sent;
|
|
1620
|
+
abort = _yield$handleRegistra2.finalError;
|
|
1536
1621
|
if (!(abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD)) {
|
|
1537
1622
|
_context24.next = 10;
|
|
1538
1623
|
break;
|
|
@@ -1616,36 +1701,35 @@ var Registration = exports.Registration = /*#__PURE__*/function () {
|
|
|
1616
1701
|
key: "deregister",
|
|
1617
1702
|
value: function () {
|
|
1618
1703
|
var _deregister = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
|
|
1619
|
-
var _this$deviceInfo$devi2, _this$deviceInfo$devi3, _t8;
|
|
1704
|
+
var loggerContext, _this$deviceInfo$devi2, _this$deviceInfo$devi3, _t8;
|
|
1620
1705
|
return _regenerator.default.wrap(function (_context27) {
|
|
1621
1706
|
while (1) switch (_context27.prev = _context27.next) {
|
|
1622
1707
|
case 0:
|
|
1623
|
-
|
|
1624
|
-
_context27.next = 1;
|
|
1625
|
-
return this.deleteRegistration(this.activeMobiusUrl, (_this$deviceInfo$devi2 = this.deviceInfo.device) === null || _this$deviceInfo$devi2 === void 0 ? void 0 : _this$deviceInfo$devi2.deviceId, (_this$deviceInfo$devi3 = this.deviceInfo.device) === null || _this$deviceInfo$devi3 === void 0 ? void 0 : _this$deviceInfo$devi3.clientDeviceUri);
|
|
1626
|
-
case 1:
|
|
1627
|
-
_Logger.default.log('Registration successfully deregistered', {
|
|
1708
|
+
loggerContext = {
|
|
1628
1709
|
file: _constants2.REGISTRATION_FILE,
|
|
1629
1710
|
method: _constants2.METHODS.DEREGISTER
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
|
|
1711
|
+
};
|
|
1712
|
+
_Logger.default.info(_constants.METHOD_START_MESSAGE, loggerContext);
|
|
1713
|
+
_context27.prev = 1;
|
|
1714
|
+
_context27.next = 2;
|
|
1715
|
+
return this.deleteRegistration(this.activeMobiusUrl, (_this$deviceInfo$devi2 = this.deviceInfo.device) === null || _this$deviceInfo$devi2 === void 0 ? void 0 : _this$deviceInfo$devi2.deviceId, (_this$deviceInfo$devi3 = this.deviceInfo.device) === null || _this$deviceInfo$devi3 === void 0 ? void 0 : _this$deviceInfo$devi3.clientDeviceUri);
|
|
1633
1716
|
case 2:
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
file: _constants2.REGISTRATION_FILE,
|
|
1638
|
-
method: _constants2.METHODS.DEREGISTER
|
|
1639
|
-
});
|
|
1717
|
+
_Logger.default.log('Registration successfully deregistered', loggerContext);
|
|
1718
|
+
_context27.next = 4;
|
|
1719
|
+
break;
|
|
1640
1720
|
case 3:
|
|
1721
|
+
_context27.prev = 3;
|
|
1722
|
+
_t8 = _context27["catch"](1);
|
|
1723
|
+
_Logger.default.warn("Delete failed with Mobius: ".concat((0, _stringify.default)(_t8)), loggerContext);
|
|
1724
|
+
case 4:
|
|
1641
1725
|
this.clearKeepaliveTimer();
|
|
1642
1726
|
this.setStatus(_types2.RegistrationStatus.INACTIVE);
|
|
1643
1727
|
this.clearFailoverState();
|
|
1644
|
-
case
|
|
1728
|
+
case 5:
|
|
1645
1729
|
case "end":
|
|
1646
1730
|
return _context27.stop();
|
|
1647
1731
|
}
|
|
1648
|
-
}, _callee26, this, [[
|
|
1732
|
+
}, _callee26, this, [[1, 3]]);
|
|
1649
1733
|
}));
|
|
1650
1734
|
function deregister() {
|
|
1651
1735
|
return _deregister.apply(this, arguments);
|