@webex/calling 3.12.0 → 3.13.0-next.1
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/CallRecording/CallRecording.js +160 -0
- package/dist/CallRecording/CallRecording.js.map +1 -0
- package/dist/CallRecording/CallRecording.test.js +257 -0
- package/dist/CallRecording/CallRecording.test.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js +748 -0
- package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js +824 -0
- package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -0
- package/dist/CallRecording/callRecordingFixtures.js +266 -0
- package/dist/CallRecording/callRecordingFixtures.js.map +1 -0
- package/dist/CallRecording/constants.js +35 -0
- package/dist/CallRecording/constants.js.map +1 -0
- package/dist/CallRecording/types.js +142 -0
- package/dist/CallRecording/types.js.map +1 -0
- package/dist/CallRecording/userhub.js +117 -0
- package/dist/CallRecording/userhub.js.map +1 -0
- package/dist/CallRecording/utils.js +42 -0
- package/dist/CallRecording/utils.js.map +1 -0
- package/dist/CallRecording/utils.test.js +97 -0
- package/dist/CallRecording/utils.test.js.map +1 -0
- package/dist/CallingClient/CallingClient.js +469 -233
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +736 -179
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/index.js +3 -1
- package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
- package/dist/CallingClient/calling/CallerId/index.test.js +12 -2
- package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +645 -458
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +928 -498
- package/dist/CallingClient/calling/call.test.js.map +1 -1
- package/dist/CallingClient/calling/callManager.js +106 -35
- package/dist/CallingClient/calling/callManager.js.map +1 -1
- package/dist/CallingClient/calling/callManager.test.js +140 -0
- package/dist/CallingClient/calling/callManager.test.js.map +1 -1
- package/dist/CallingClient/calling/types.js +5 -0
- package/dist/CallingClient/calling/types.js.map +1 -1
- package/dist/CallingClient/constants.js +33 -3
- package/dist/CallingClient/constants.js.map +1 -1
- package/dist/CallingClient/line/index.js +27 -3
- package/dist/CallingClient/line/index.js.map +1 -1
- package/dist/CallingClient/line/line.test.js +102 -17
- package/dist/CallingClient/line/line.test.js.map +1 -1
- package/dist/CallingClient/registration/register.js +971 -506
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +946 -61
- package/dist/CallingClient/registration/register.test.js.map +1 -1
- package/dist/CallingClient/registration/types.js +26 -0
- package/dist/CallingClient/registration/types.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.js +41 -104
- package/dist/CallingClient/registration/webWorker.js.map +1 -1
- package/dist/CallingClient/registration/webWorker.test.js +39 -153
- package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js +1 -1
- package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
- package/dist/CallingClient/types.js +7 -0
- package/dist/CallingClient/types.js.map +1 -1
- package/dist/CallingClient/utils/constants.js +58 -0
- package/dist/CallingClient/utils/constants.js.map +1 -0
- package/dist/CallingClient/utils/index.js +63 -0
- package/dist/CallingClient/utils/index.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js +122 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.js.map +1 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js +221 -0
- package/dist/CallingClient/utils/mobiusSocketMapper.test.js.map +1 -0
- package/dist/CallingClient/utils/request.js +435 -0
- package/dist/CallingClient/utils/request.js.map +1 -0
- package/dist/CallingClient/utils/request.test.js +999 -0
- package/dist/CallingClient/utils/request.test.js.map +1 -0
- package/dist/CallingClient/utils/types.js +7 -0
- package/dist/CallingClient/utils/types.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js +70 -0
- package/dist/CallingClient/utils/wsFeatureFlag.js.map +1 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js +139 -0
- package/dist/CallingClient/utils/wsFeatureFlag.test.js.map +1 -0
- package/dist/Contacts/ContactsClient.js +13 -11
- package/dist/Contacts/ContactsClient.js.map +1 -1
- package/dist/Contacts/ContactsClient.test.js +3 -8
- package/dist/Contacts/ContactsClient.test.js.map +1 -1
- package/dist/Errors/types.js +2 -0
- package/dist/Errors/types.js.map +1 -1
- package/dist/Events/types.js +38 -11
- package/dist/Events/types.js.map +1 -1
- package/dist/Metrics/index.js +63 -2
- package/dist/Metrics/index.js.map +1 -1
- package/dist/Metrics/index.test.js +357 -1
- package/dist/Metrics/index.test.js.map +1 -1
- package/dist/Metrics/types.js +19 -1
- package/dist/Metrics/types.js.map +1 -1
- package/dist/SDKConnector/types.js.map +1 -1
- package/dist/api.js +56 -0
- package/dist/api.js.map +1 -1
- package/dist/common/Utils.js +252 -127
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +493 -229
- package/dist/common/Utils.test.js.map +1 -1
- package/dist/common/callUtils.js +187 -0
- package/dist/common/callUtils.js.map +1 -0
- package/dist/common/callUtils.test.js +313 -0
- package/dist/common/callUtils.test.js.map +1 -0
- package/dist/common/constants.js +27 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/index.js +11 -0
- package/dist/common/index.js.map +1 -1
- package/dist/common/testUtil.js +11 -5
- package/dist/common/testUtil.js.map +1 -1
- package/dist/common/types.js +3 -0
- package/dist/common/types.js.map +1 -1
- package/dist/index.js +171 -40
- package/dist/index.js.map +1 -1
- package/dist/mobius-socket/config.js +24 -0
- package/dist/mobius-socket/config.js.map +1 -0
- package/dist/mobius-socket/errors.js +143 -0
- package/dist/mobius-socket/errors.js.map +1 -0
- package/dist/mobius-socket/errors.test.js +20 -0
- package/dist/mobius-socket/errors.test.js.map +1 -0
- package/dist/mobius-socket/index.js +57 -0
- package/dist/mobius-socket/index.js.map +1 -0
- package/dist/mobius-socket/mobius-socket-events.test.js +493 -0
- package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.js +849 -0
- package/dist/mobius-socket/mobius-socket.js.map +1 -0
- package/dist/mobius-socket/mobius-socket.test.js +1898 -0
- package/dist/mobius-socket/mobius-socket.test.js.map +1 -0
- package/dist/mobius-socket/socket/constants.js +55 -0
- package/dist/mobius-socket/socket/constants.js.map +1 -0
- package/dist/mobius-socket/socket/index.js +15 -0
- package/dist/mobius-socket/socket/index.js.map +1 -0
- package/dist/mobius-socket/socket/socket-base.js +614 -0
- package/dist/mobius-socket/socket/socket-base.js.map +1 -0
- package/dist/mobius-socket/socket/socket.js +19 -0
- package/dist/mobius-socket/socket/socket.js.map +1 -0
- package/dist/mobius-socket/socket/socket.shim.js +26 -0
- package/dist/mobius-socket/socket/socket.shim.js.map +1 -0
- package/dist/mobius-socket/socket/types.js +7 -0
- package/dist/mobius-socket/socket/types.js.map +1 -0
- package/dist/mobius-socket/socket.test.js +747 -0
- package/dist/mobius-socket/socket.test.js.map +1 -0
- package/dist/mobius-socket/test/mocha-helpers.js +23 -0
- package/dist/mobius-socket/test/mocha-helpers.js.map +1 -0
- package/dist/mobius-socket/test/promise-tick.js +28 -0
- package/dist/mobius-socket/test/promise-tick.js.map +1 -0
- package/dist/mobius-socket/types.js +7 -0
- package/dist/mobius-socket/types.js.map +1 -0
- package/dist/module/CallRecording/CallRecording.js +56 -0
- package/dist/module/CallRecording/WxcCallRecordingConnector.js +349 -0
- package/dist/module/CallRecording/callRecordingFixtures.js +231 -0
- package/dist/module/CallRecording/constants.js +27 -0
- package/dist/module/CallRecording/types.js +19 -0
- package/dist/module/CallRecording/userhub.js +100 -0
- package/dist/module/CallRecording/utils.js +14 -0
- package/dist/module/CallingClient/CallingClient.js +137 -20
- package/dist/module/CallingClient/calling/CallerId/index.js +2 -2
- package/dist/module/CallingClient/calling/call.js +207 -68
- package/dist/module/CallingClient/calling/callManager.js +51 -11
- package/dist/module/CallingClient/calling/types.js +2 -0
- package/dist/module/CallingClient/constants.js +28 -0
- package/dist/module/CallingClient/line/index.js +11 -3
- package/dist/module/CallingClient/registration/register.js +297 -68
- package/dist/module/CallingClient/registration/types.js +5 -1
- package/dist/module/CallingClient/registration/webWorker.js +42 -61
- package/dist/module/CallingClient/registration/webWorkerStr.js +47 -82
- package/dist/module/CallingClient/utils/constants.js +36 -0
- package/dist/module/CallingClient/utils/index.js +5 -0
- package/dist/module/CallingClient/utils/mobiusSocketMapper.js +72 -0
- package/dist/module/CallingClient/utils/request.js +211 -0
- package/dist/module/CallingClient/utils/types.js +1 -0
- package/dist/module/CallingClient/utils/wsFeatureFlag.js +41 -0
- package/dist/module/Contacts/ContactsClient.js +1 -1
- package/dist/module/Errors/types.js +2 -0
- package/dist/module/Events/types.js +23 -10
- package/dist/module/Metrics/index.js +48 -1
- package/dist/module/Metrics/types.js +18 -0
- package/dist/module/api.js +3 -2
- package/dist/module/common/Utils.js +103 -58
- package/dist/module/common/callUtils.js +90 -0
- package/dist/module/common/constants.js +11 -0
- package/dist/module/common/index.js +1 -0
- package/dist/module/common/testUtil.js +7 -1
- package/dist/module/common/types.js +3 -0
- package/dist/module/index.js +7 -3
- package/dist/module/mobius-socket/config.js +15 -0
- package/dist/module/mobius-socket/errors.js +58 -0
- package/dist/module/mobius-socket/index.js +24 -0
- package/dist/module/mobius-socket/mobius-socket.js +593 -0
- package/dist/module/mobius-socket/socket/constants.js +26 -0
- package/dist/module/mobius-socket/socket/index.js +4 -0
- package/dist/module/mobius-socket/socket/socket-base.js +376 -0
- package/dist/module/mobius-socket/socket/socket.js +9 -0
- package/dist/module/mobius-socket/socket/socket.shim.js +12 -0
- package/dist/module/mobius-socket/socket/types.js +1 -0
- package/dist/module/mobius-socket/types.js +1 -0
- package/dist/types/CallRecording/CallRecording.d.ts +18 -0
- package/dist/types/CallRecording/CallRecording.d.ts.map +1 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +27 -0
- package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts +152 -0
- package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -0
- package/dist/types/CallRecording/constants.d.ts +28 -0
- package/dist/types/CallRecording/constants.d.ts.map +1 -0
- package/dist/types/CallRecording/types.d.ts +184 -0
- package/dist/types/CallRecording/types.d.ts.map +1 -0
- package/dist/types/CallRecording/userhub.d.ts +44 -0
- package/dist/types/CallRecording/userhub.d.ts.map +1 -0
- package/dist/types/CallRecording/utils.d.ts +3 -0
- package/dist/types/CallRecording/utils.d.ts.map +1 -0
- package/dist/types/CallingClient/CallingClient.d.ts +8 -0
- package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/call.d.ts +17 -3
- package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/callManager.d.ts +8 -4
- package/dist/types/CallingClient/calling/callManager.d.ts.map +1 -1
- package/dist/types/CallingClient/calling/types.d.ts +38 -9
- package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
- package/dist/types/CallingClient/constants.d.ts +28 -0
- package/dist/types/CallingClient/constants.d.ts.map +1 -1
- package/dist/types/CallingClient/line/index.d.ts +3 -2
- package/dist/types/CallingClient/line/index.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/register.d.ts +9 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +26 -2
- package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
- package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
- package/dist/types/CallingClient/types.d.ts +6 -2
- package/dist/types/CallingClient/types.d.ts.map +1 -1
- package/dist/types/CallingClient/utils/constants.d.ts +35 -0
- package/dist/types/CallingClient/utils/constants.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/index.d.ts +6 -0
- package/dist/types/CallingClient/utils/index.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts +5 -0
- package/dist/types/CallingClient/utils/mobiusSocketMapper.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/request.d.ts +28 -0
- package/dist/types/CallingClient/utils/request.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/types.d.ts +34 -0
- package/dist/types/CallingClient/utils/types.d.ts.map +1 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts +4 -0
- package/dist/types/CallingClient/utils/wsFeatureFlag.d.ts.map +1 -0
- package/dist/types/Errors/types.d.ts +2 -0
- package/dist/types/Errors/types.d.ts.map +1 -1
- package/dist/types/Events/types.d.ts +80 -16
- package/dist/types/Events/types.d.ts.map +1 -1
- package/dist/types/Metrics/index.d.ts.map +1 -1
- package/dist/types/Metrics/types.d.ts +19 -2
- package/dist/types/Metrics/types.d.ts.map +1 -1
- package/dist/types/SDKConnector/types.d.ts +40 -12
- package/dist/types/SDKConnector/types.d.ts.map +1 -1
- package/dist/types/api.d.ts +6 -4
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/common/Utils.d.ts +11 -5
- package/dist/types/common/Utils.d.ts.map +1 -1
- package/dist/types/common/callUtils.d.ts +6 -0
- package/dist/types/common/callUtils.d.ts.map +1 -0
- package/dist/types/common/constants.d.ts +6 -0
- package/dist/types/common/constants.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +1 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/testUtil.d.ts +6 -1
- package/dist/types/common/testUtil.d.ts.map +1 -1
- package/dist/types/common/types.d.ts +5 -1
- package/dist/types/common/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +9 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/mobius-socket/config.d.ts +17 -0
- package/dist/types/mobius-socket/config.d.ts.map +1 -0
- package/dist/types/mobius-socket/errors.d.ts +32 -0
- package/dist/types/mobius-socket/errors.d.ts.map +1 -0
- package/dist/types/mobius-socket/index.d.ts +14 -0
- package/dist/types/mobius-socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts +48 -0
- package/dist/types/mobius-socket/mobius-socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/constants.d.ts +27 -0
- package/dist/types/mobius-socket/socket/constants.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/index.d.ts +5 -0
- package/dist/types/mobius-socket/socket/index.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts +43 -0
- package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts +6 -0
- package/dist/types/mobius-socket/socket/socket.shim.d.ts.map +1 -0
- package/dist/types/mobius-socket/socket/types.d.ts +61 -0
- package/dist/types/mobius-socket/socket/types.d.ts.map +1 -0
- package/dist/types/mobius-socket/types.d.ts +21 -0
- package/dist/types/mobius-socket/types.d.ts.map +1 -0
- package/package.json +21 -5
- package/src/mobius-socket/socket/socket.shim.ts +22 -0
- package/src/mobius-socket/socket/socket.ts +14 -0
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { v4 as uuid } from 'uuid';
|
|
2
1
|
import { METHOD_START_MESSAGE } from '../../common/constants';
|
|
3
|
-
import { emitFinalFailure, handleRegistrationErrors, uploadLogs } from '../../common';
|
|
2
|
+
import { emitFinalFailure, getHostIps, handleRegistrationErrors, uploadLogs } from '../../common';
|
|
4
3
|
import webWorkerStr from './webWorkerStr';
|
|
5
4
|
import { METRIC_EVENT, METRIC_TYPE, REG_ACTION, } from '../../Metrics/types';
|
|
6
5
|
import { getMetricManager } from '../../Metrics';
|
|
7
6
|
import { getCallManager } from '../calling';
|
|
8
7
|
import log from '../../Logger';
|
|
8
|
+
import { HARD_STOP_REASON } from './types';
|
|
9
9
|
import SDKConnector from '../../SDKConnector';
|
|
10
10
|
import { ALLOWED_SERVICES, HTTP_METHODS, RegistrationStatus, ServiceIndicator, WorkerMessageType, } from '../../common/types';
|
|
11
|
-
import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT,
|
|
11
|
+
import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT, BASE_REG_RETRY_TIMER_VAL_IN_SEC, BASE_REG_TIMER_MFACTOR, SEC_TO_MSEC_MFACTOR, REG_RANDOM_T_FACTOR_UPPER_LIMIT, REG_TRY_BACKUP_TIMER_VAL_IN_SEC, MINUTES_TO_SEC_MFACTOR, REG_429_RETRY_UTIL, FAILBACK_UTIL, REGISTRATION_FILE, DEFAULT_REHOMING_INTERVAL_MIN, DEFAULT_REHOMING_INTERVAL_MAX, DEFAULT_KEEPALIVE_INTERVAL, FAILOVER_UTIL, REGISTER_UTIL, RETRY_TIMER_UPPER_LIMIT, KEEPALIVE_UTIL, REGISTRATION_UTIL, METHODS, URL_ENDPOINT, RECONNECT_ON_FAILURE_UTIL, FAILOVER_CACHE_PREFIX, REG_FAILBACK_429_MAX_RETRIES, } from '../constants';
|
|
12
12
|
import { LINE_EVENTS } from '../line/types';
|
|
13
|
+
import { ERROR_CODE } from '../../Errors/types';
|
|
14
|
+
import { APIRequest } from '../utils/request';
|
|
13
15
|
export class Registration {
|
|
14
16
|
sdkConnector;
|
|
15
17
|
webex;
|
|
@@ -36,6 +38,8 @@ export class Registration {
|
|
|
36
38
|
retryAfter;
|
|
37
39
|
scheduled429Retry = false;
|
|
38
40
|
webWorker;
|
|
41
|
+
sessionSuperseded = false;
|
|
42
|
+
apiRequest;
|
|
39
43
|
constructor(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
|
|
40
44
|
this.jwe = jwe;
|
|
41
45
|
this.sdkConnector = SDKConnector;
|
|
@@ -57,6 +61,12 @@ export class Registration {
|
|
|
57
61
|
this.lineEmitter = lineEmitter;
|
|
58
62
|
this.primaryMobiusUris = [];
|
|
59
63
|
this.backupMobiusUris = [];
|
|
64
|
+
this.apiRequest = APIRequest.getInstance({ webex: this.webex });
|
|
65
|
+
}
|
|
66
|
+
getServerType(url) {
|
|
67
|
+
return ((this.primaryMobiusUris.includes(url) && 'PRIMARY') ||
|
|
68
|
+
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
69
|
+
'UNKNOWN');
|
|
60
70
|
}
|
|
61
71
|
getFailoverCacheKey() {
|
|
62
72
|
return `${FAILOVER_CACHE_PREFIX}.${this.userId || 'unknown'}`;
|
|
@@ -131,16 +141,22 @@ export class Registration {
|
|
|
131
141
|
}
|
|
132
142
|
async deleteRegistration(url, deviceId, deviceUrl) {
|
|
133
143
|
let response;
|
|
144
|
+
const requestObj = {
|
|
145
|
+
uri: `${url}${DEVICES_ENDPOINT_RESOURCE}/${deviceId}`,
|
|
146
|
+
method: HTTP_METHODS.DELETE,
|
|
147
|
+
headers: {
|
|
148
|
+
[CISCO_DEVICE_URL]: deviceUrl,
|
|
149
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
150
|
+
},
|
|
151
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
152
|
+
};
|
|
153
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
154
|
+
requestObj.body = {
|
|
155
|
+
deviceId,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
134
158
|
try {
|
|
135
|
-
response = await
|
|
136
|
-
method: HTTP_METHODS.DELETE,
|
|
137
|
-
headers: {
|
|
138
|
-
[CISCO_DEVICE_URL]: deviceUrl,
|
|
139
|
-
Authorization: await this.webex.credentials.getUserToken(),
|
|
140
|
-
trackingId: `${WEBEX_WEB_CLIENT}_${uuid()}`,
|
|
141
|
-
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
142
|
-
},
|
|
143
|
-
});
|
|
159
|
+
response = await this.apiRequest.makeRequest(requestObj);
|
|
144
160
|
}
|
|
145
161
|
catch (error) {
|
|
146
162
|
log.warn(`Delete failed with Mobius: ${JSON.stringify(error)}`, {
|
|
@@ -151,15 +167,17 @@ export class Registration {
|
|
|
151
167
|
}
|
|
152
168
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
153
169
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
154
|
-
return response
|
|
170
|
+
return response;
|
|
155
171
|
}
|
|
156
172
|
async postRegistration(url) {
|
|
173
|
+
const hostIps = getHostIps();
|
|
157
174
|
const deviceInfo = {
|
|
158
175
|
userId: this.userId,
|
|
159
176
|
clientDeviceUri: this.webex.internal.device.url,
|
|
160
177
|
serviceData: this.jwe ? { ...this.serviceData, jwe: this.jwe } : this.serviceData,
|
|
178
|
+
hostIps,
|
|
161
179
|
};
|
|
162
|
-
return this.
|
|
180
|
+
return this.apiRequest.makeRequest({
|
|
163
181
|
uri: `${url}device`,
|
|
164
182
|
method: HTTP_METHODS.POST,
|
|
165
183
|
headers: {
|
|
@@ -171,7 +189,23 @@ export class Registration {
|
|
|
171
189
|
});
|
|
172
190
|
}
|
|
173
191
|
async restorePreviousRegistration(caller) {
|
|
192
|
+
const loggerContext = {
|
|
193
|
+
file: REGISTRATION_FILE,
|
|
194
|
+
method: METHODS.RESTORE_PREVIOUS_REGISTRATION,
|
|
195
|
+
};
|
|
196
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}, activeMobiusUrl: ${this.activeMobiusUrl}`, loggerContext);
|
|
174
197
|
let abort = false;
|
|
198
|
+
if (this.apiRequest.isSocketEnabled() &&
|
|
199
|
+
`${this.apiRequest.getConnectedWebSocketUrl()}/` !== this.activeMobiusUrl) {
|
|
200
|
+
log.info(`Disconnecting from Mobius socket to restore previous registration.`, {
|
|
201
|
+
file: REGISTRATION_FILE,
|
|
202
|
+
method: 'restorePreviousRegistration',
|
|
203
|
+
});
|
|
204
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
205
|
+
code: 3050,
|
|
206
|
+
reason: 'done (permanent)',
|
|
207
|
+
});
|
|
208
|
+
}
|
|
175
209
|
if (this.activeMobiusUrl) {
|
|
176
210
|
abort = await this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
|
|
177
211
|
if (this.retryAfter) {
|
|
@@ -185,22 +219,48 @@ export class Registration {
|
|
|
185
219
|
abort = await this.attemptRegistrationWithServers(caller, this.backupMobiusUris);
|
|
186
220
|
}
|
|
187
221
|
else {
|
|
188
|
-
this.restartRegistration(caller);
|
|
222
|
+
await this.restartRegistration(caller);
|
|
189
223
|
}
|
|
190
224
|
this.retryAfter = undefined;
|
|
225
|
+
log.log(`restorePreviousRegistration completed via 429 retry-after path - caller: ${caller}`, loggerContext);
|
|
191
226
|
return true;
|
|
192
227
|
}
|
|
193
228
|
}
|
|
229
|
+
log.log(`restorePreviousRegistration completed - caller: ${caller}, deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
194
230
|
return abort;
|
|
195
231
|
}
|
|
196
232
|
async handle404KeepaliveFailure(caller) {
|
|
233
|
+
const loggerContext = {
|
|
234
|
+
file: REGISTRATION_FILE,
|
|
235
|
+
method: METHODS.HANDLE_404_KEEPALIVE_FAILURE,
|
|
236
|
+
};
|
|
237
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}`, loggerContext);
|
|
197
238
|
if (caller === KEEPALIVE_UTIL) {
|
|
198
239
|
const abort = await this.attemptRegistrationWithServers(caller);
|
|
199
240
|
if (!abort && !this.isDeviceRegistered()) {
|
|
241
|
+
log.warn('Keepalive 404 recovery: re-registration did not complete, starting failover timer', loggerContext);
|
|
200
242
|
await this.startFailoverTimer();
|
|
201
243
|
}
|
|
244
|
+
else {
|
|
245
|
+
log.log(`Keepalive 404 recovery handled - deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
246
|
+
}
|
|
202
247
|
}
|
|
203
248
|
}
|
|
249
|
+
async handle409KeepaliveFailure(lineError, error, serverType, keepaliveRetryCount) {
|
|
250
|
+
const loggerContext = {
|
|
251
|
+
file: REGISTRATION_FILE,
|
|
252
|
+
method: METHODS.HANDLE_409_KEEPALIVE_FAILURE,
|
|
253
|
+
};
|
|
254
|
+
this.sessionSuperseded = true;
|
|
255
|
+
log.warn(`Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ${keepaliveRetryCount}`, loggerContext);
|
|
256
|
+
this.clearKeepaliveTimer();
|
|
257
|
+
this.metricManager.submitRegistrationMetric(METRIC_EVENT.KEEPALIVE_ERROR, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, METHODS.HANDLE_409_KEEPALIVE_FAILURE, serverType, error.headers?.trackingid ?? '', keepaliveRetryCount, lineError);
|
|
258
|
+
await this.registrationCleanup(METHODS.HANDLE_409_KEEPALIVE_FAILURE, {
|
|
259
|
+
reason: HARD_STOP_REASON.SESSION_SUPERSEDED,
|
|
260
|
+
error: lineError,
|
|
261
|
+
});
|
|
262
|
+
await uploadLogs();
|
|
263
|
+
}
|
|
204
264
|
async handle429Retry(retryAfter, caller) {
|
|
205
265
|
if (caller === FAILBACK_UTIL) {
|
|
206
266
|
if (this.failback429RetryAttempts >= REG_FAILBACK_429_MAX_RETRIES) {
|
|
@@ -228,7 +288,7 @@ export class Registration {
|
|
|
228
288
|
method: REG_429_RETRY_UTIL,
|
|
229
289
|
});
|
|
230
290
|
await this.startKeepaliveTimer(this.deviceInfo.device?.uri, this.deviceInfo.keepaliveInterval, 'UNKNOWN');
|
|
231
|
-
}, retryAfter * 1000);
|
|
291
|
+
}, (retryAfter - Number(this.deviceInfo.keepaliveInterval || 0)) * 1000);
|
|
232
292
|
}
|
|
233
293
|
else {
|
|
234
294
|
this.retryAfter = retryAfter;
|
|
@@ -279,6 +339,14 @@ export class Registration {
|
|
|
279
339
|
log.log(`Scheduled retry with primary in ${interval} seconds, number of attempts : ${attempt}`, loggerContext);
|
|
280
340
|
}
|
|
281
341
|
else if (this.backupMobiusUris.length) {
|
|
342
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
343
|
+
log.info('Disconnecting from primary Mobius socket for failover to backup servers', loggerContext);
|
|
344
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
345
|
+
code: 3050,
|
|
346
|
+
reason: 'done (permanent)',
|
|
347
|
+
});
|
|
348
|
+
log.log('Mobius socket disconnect complete prior to backup failover', loggerContext);
|
|
349
|
+
}
|
|
282
350
|
this.saveFailoverState({
|
|
283
351
|
attempt,
|
|
284
352
|
timeElapsed,
|
|
@@ -311,7 +379,7 @@ export class Registration {
|
|
|
311
379
|
await uploadLogs();
|
|
312
380
|
emitFinalFailure((clientError) => {
|
|
313
381
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
314
|
-
}, loggerContext);
|
|
382
|
+
}, loggerContext, interval < 0 ? 'Timer threshold exceeded during failover' : undefined);
|
|
315
383
|
}
|
|
316
384
|
}
|
|
317
385
|
clearFailbackTimer() {
|
|
@@ -320,11 +388,25 @@ export class Registration {
|
|
|
320
388
|
this.failbackTimer = undefined;
|
|
321
389
|
}
|
|
322
390
|
}
|
|
391
|
+
async postKeepAlive(deviceUrl, url) {
|
|
392
|
+
return this.apiRequest.makeRequest({
|
|
393
|
+
uri: `${url}/status`,
|
|
394
|
+
method: HTTP_METHODS.POST,
|
|
395
|
+
headers: {
|
|
396
|
+
[CISCO_DEVICE_URL]: deviceUrl,
|
|
397
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
398
|
+
},
|
|
399
|
+
body: {
|
|
400
|
+
deviceId: this.deviceInfo.device?.deviceId,
|
|
401
|
+
},
|
|
402
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
323
405
|
async isPrimaryActive() {
|
|
324
406
|
let status;
|
|
325
407
|
for (const mobiusUrl of this.primaryMobiusUris) {
|
|
326
408
|
try {
|
|
327
|
-
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/');
|
|
409
|
+
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/').replace('wss://', 'https://');
|
|
328
410
|
const response = await this.webex.request({
|
|
329
411
|
uri: `${baseUri}ping`,
|
|
330
412
|
method: HTTP_METHODS.GET,
|
|
@@ -362,14 +444,23 @@ export class Registration {
|
|
|
362
444
|
this.rehomingIntervalMin);
|
|
363
445
|
}
|
|
364
446
|
initiateFailback() {
|
|
447
|
+
const loggerContext = {
|
|
448
|
+
file: REGISTRATION_FILE,
|
|
449
|
+
method: METHODS.INITIATE_FAILBACK,
|
|
450
|
+
};
|
|
365
451
|
if (this.isFailbackRequired()) {
|
|
366
452
|
if (!this.failbackTimer) {
|
|
367
453
|
this.failback429RetryAttempts = 0;
|
|
368
454
|
const intervalInMinutes = this.getFailbackInterval();
|
|
455
|
+
log.info(`Scheduling failback to primary - intervalMinutes: ${intervalInMinutes}`, loggerContext);
|
|
369
456
|
this.startFailbackTimer(intervalInMinutes * MINUTES_TO_SEC_MFACTOR);
|
|
370
457
|
}
|
|
458
|
+
else {
|
|
459
|
+
log.info('Failback timer already scheduled, skipping', loggerContext);
|
|
460
|
+
}
|
|
371
461
|
}
|
|
372
462
|
else {
|
|
463
|
+
log.info('Failback not required, clearing any pending failback timer', loggerContext);
|
|
373
464
|
this.failback429RetryAttempts = 0;
|
|
374
465
|
this.clearFailbackTimer();
|
|
375
466
|
}
|
|
@@ -382,15 +473,25 @@ export class Registration {
|
|
|
382
473
|
});
|
|
383
474
|
}
|
|
384
475
|
async executeFailback() {
|
|
476
|
+
const loggerContext = {
|
|
477
|
+
file: REGISTRATION_FILE,
|
|
478
|
+
method: METHODS.EXECUTE_FAILBACK,
|
|
479
|
+
};
|
|
480
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
385
481
|
await this.mutex.runExclusive(async () => {
|
|
386
482
|
if (this.isFailbackRequired()) {
|
|
387
483
|
const primaryServerStatus = await this.isPrimaryActive();
|
|
388
484
|
if (Object.keys(this.callManager.getActiveCalls()).length === 0 && primaryServerStatus) {
|
|
389
|
-
log.info(`Attempting failback to primary.`,
|
|
390
|
-
file: REGISTRATION_FILE,
|
|
391
|
-
method: this.executeFailback.name,
|
|
392
|
-
});
|
|
485
|
+
log.info(`Attempting failback to primary.`, loggerContext);
|
|
393
486
|
await this.deregister();
|
|
487
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
488
|
+
log.info('Disconnecting from backup Mobius socket for failback to primary', loggerContext);
|
|
489
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
490
|
+
code: 3050,
|
|
491
|
+
reason: 'done (permanent)',
|
|
492
|
+
});
|
|
493
|
+
log.log('Mobius socket disconnect complete prior to primary failback', loggerContext);
|
|
494
|
+
}
|
|
394
495
|
const abort = await this.attemptRegistrationWithServers(FAILBACK_UTIL);
|
|
395
496
|
if (this.scheduled429Retry || abort || this.isDeviceRegistered()) {
|
|
396
497
|
return;
|
|
@@ -401,7 +502,7 @@ export class Registration {
|
|
|
401
502
|
return;
|
|
402
503
|
}
|
|
403
504
|
if (!this.isDeviceRegistered()) {
|
|
404
|
-
await this.restartRegistration(
|
|
505
|
+
await this.restartRegistration(loggerContext.method);
|
|
405
506
|
}
|
|
406
507
|
else {
|
|
407
508
|
this.failbackTimer = undefined;
|
|
@@ -409,10 +510,7 @@ export class Registration {
|
|
|
409
510
|
}
|
|
410
511
|
}
|
|
411
512
|
else {
|
|
412
|
-
log.info('Active calls present or primary Mobius is down, deferring failback to next cycle.',
|
|
413
|
-
file: REGISTRATION_FILE,
|
|
414
|
-
method: this.executeFailback.name,
|
|
415
|
-
});
|
|
513
|
+
log.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', loggerContext);
|
|
416
514
|
this.failbackTimer = undefined;
|
|
417
515
|
this.initiateFailback();
|
|
418
516
|
}
|
|
@@ -442,12 +540,18 @@ export class Registration {
|
|
|
442
540
|
this.registrationStatus = value;
|
|
443
541
|
}
|
|
444
542
|
async restartRegistration(caller) {
|
|
543
|
+
const loggerContext = {
|
|
544
|
+
file: REGISTRATION_FILE,
|
|
545
|
+
method: METHODS.RESTART_REGISTRATION,
|
|
546
|
+
};
|
|
547
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}`, loggerContext);
|
|
445
548
|
this.clearFailbackTimer();
|
|
446
549
|
this.failback429RetryAttempts = 0;
|
|
447
550
|
const abort = await this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
|
|
448
551
|
if (!abort && !this.isDeviceRegistered()) {
|
|
449
552
|
await this.startFailoverTimer();
|
|
450
553
|
}
|
|
554
|
+
log.log(`restartRegistration completed - caller: ${caller}, deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
451
555
|
}
|
|
452
556
|
async handleConnectionRestoration(retry) {
|
|
453
557
|
log.info(METHOD_START_MESSAGE, {
|
|
@@ -500,7 +604,14 @@ export class Registration {
|
|
|
500
604
|
};
|
|
501
605
|
}
|
|
502
606
|
async triggerRegistration() {
|
|
607
|
+
const loggerContext = {
|
|
608
|
+
file: REGISTRATION_FILE,
|
|
609
|
+
method: METHODS.TRIGGER_REGISTRATION,
|
|
610
|
+
};
|
|
611
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
612
|
+
this.sessionSuperseded = false;
|
|
503
613
|
if (await this.resumeFailover()) {
|
|
614
|
+
log.info('Registration trigger handled by resumeFailover path', loggerContext);
|
|
504
615
|
return;
|
|
505
616
|
}
|
|
506
617
|
if (this.primaryMobiusUris.length > 0) {
|
|
@@ -508,43 +619,58 @@ export class Registration {
|
|
|
508
619
|
if (!this.isDeviceRegistered() && !abort) {
|
|
509
620
|
await this.startFailoverTimer();
|
|
510
621
|
}
|
|
622
|
+
log.log(`triggerRegistration completed - deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
623
|
+
}
|
|
624
|
+
else {
|
|
625
|
+
log.warn('triggerRegistration skipped: no primary Mobius URIs available', loggerContext);
|
|
511
626
|
}
|
|
512
627
|
}
|
|
513
628
|
async attemptRegistrationWithServers(caller, servers = this.primaryMobiusUris) {
|
|
629
|
+
const loggerContext = {
|
|
630
|
+
file: REGISTRATION_FILE,
|
|
631
|
+
method: REGISTER_UTIL,
|
|
632
|
+
};
|
|
633
|
+
if (this.sessionSuperseded) {
|
|
634
|
+
log.warn(`Session superseded, skipping registration attempt - caller: ${caller}`, {
|
|
635
|
+
file: REGISTRATION_FILE,
|
|
636
|
+
method: caller,
|
|
637
|
+
});
|
|
638
|
+
return true;
|
|
639
|
+
}
|
|
514
640
|
let abort = false;
|
|
515
641
|
this.retryAfter = undefined;
|
|
642
|
+
let connectedWebSocketUrl;
|
|
516
643
|
if (this.failoverImmediately) {
|
|
517
644
|
return abort;
|
|
518
645
|
}
|
|
519
646
|
if (this.isDeviceRegistered()) {
|
|
520
|
-
log.info(`[${caller}] : Device already registered with : ${this.activeMobiusUrl}`,
|
|
521
|
-
file: REGISTRATION_FILE,
|
|
522
|
-
method: REGISTER_UTIL,
|
|
523
|
-
});
|
|
647
|
+
log.info(`[${caller}] : Device already registered with : ${this.activeMobiusUrl}`, loggerContext);
|
|
524
648
|
return abort;
|
|
525
649
|
}
|
|
650
|
+
if (servers.length) {
|
|
651
|
+
this.apiRequest.setSocketEnabled(servers[0].startsWith('wss://'));
|
|
652
|
+
}
|
|
526
653
|
for (const url of servers) {
|
|
527
|
-
const serverType =
|
|
528
|
-
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
529
|
-
'UNKNOWN';
|
|
654
|
+
const serverType = this.getServerType(url);
|
|
530
655
|
try {
|
|
531
656
|
abort = false;
|
|
532
657
|
this.registrationStatus = RegistrationStatus.INACTIVE;
|
|
533
658
|
this.lineEmitter(LINE_EVENTS.CONNECTING);
|
|
534
|
-
log.info(`[${caller}] : Mobius url to contact: ${url}`,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
659
|
+
log.info(`[${caller}] : Mobius url to contact: ${url}`, loggerContext);
|
|
660
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
661
|
+
const wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
662
|
+
log.info(`[${caller}] : Connecting to Mobius WebSocket - serverType: ${serverType}, wssUrl: ${wssNormalizedUrl}`, loggerContext);
|
|
663
|
+
connectedWebSocketUrl = await this.apiRequest.connectToMobiusSocket(wssNormalizedUrl);
|
|
664
|
+
connectedWebSocketUrl = connectedWebSocketUrl ? `${connectedWebSocketUrl}/` : undefined;
|
|
665
|
+
log.log(`[${caller}] : Mobius WebSocket connected - serverType: ${serverType}, connectedWebSocketUrl: ${connectedWebSocketUrl}`, loggerContext);
|
|
666
|
+
}
|
|
538
667
|
const resp = await this.postRegistration(url);
|
|
539
668
|
this.clearFailoverState();
|
|
540
669
|
this.deviceInfo = resp.body;
|
|
541
670
|
this.registrationStatus = RegistrationStatus.ACTIVE;
|
|
542
|
-
this.setActiveMobiusUrl(url);
|
|
671
|
+
this.setActiveMobiusUrl(connectedWebSocketUrl || url);
|
|
543
672
|
this.lineEmitter(LINE_EVENTS.REGISTERED, resp.body);
|
|
544
|
-
log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId} responseTrackingId: ${resp.headers?.trackingid}`,
|
|
545
|
-
file: REGISTRATION_FILE,
|
|
546
|
-
method: METHODS.REGISTER,
|
|
547
|
-
});
|
|
673
|
+
log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId} responseTrackingId: ${resp.headers?.trackingid}`, loggerContext);
|
|
548
674
|
this.setIntervalValues(this.deviceInfo);
|
|
549
675
|
this.metricManager.setDeviceInfo(this.deviceInfo);
|
|
550
676
|
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, resp.headers?.trackingid ?? '', undefined, undefined);
|
|
@@ -554,22 +680,32 @@ export class Registration {
|
|
|
554
680
|
}
|
|
555
681
|
catch (err) {
|
|
556
682
|
const body = err;
|
|
557
|
-
|
|
558
|
-
if (
|
|
683
|
+
const { finalError, shouldDisconnect } = await handleRegistrationErrors(body, (clientError, isFinalError) => {
|
|
684
|
+
if (isFinalError) {
|
|
559
685
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
560
686
|
}
|
|
561
687
|
else {
|
|
562
688
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
563
689
|
}
|
|
564
690
|
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, body.headers?.trackingid ?? '', undefined, clientError);
|
|
565
|
-
}, { method: caller, file: REGISTRATION_FILE },
|
|
691
|
+
}, { method: caller, file: REGISTRATION_FILE }, {
|
|
692
|
+
retry429Cb: (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller),
|
|
693
|
+
restoreRegCb: this.restoreRegistrationCallBack(),
|
|
694
|
+
}, servers.length);
|
|
695
|
+
abort = finalError;
|
|
566
696
|
if (this.registrationStatus === RegistrationStatus.ACTIVE) {
|
|
567
|
-
log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`,
|
|
568
|
-
file: REGISTRATION_FILE,
|
|
569
|
-
method: this.attemptRegistrationWithServers.name,
|
|
570
|
-
});
|
|
697
|
+
log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`, loggerContext);
|
|
571
698
|
break;
|
|
572
699
|
}
|
|
700
|
+
if (shouldDisconnect && this.apiRequest.isSocketEnabled()) {
|
|
701
|
+
connectedWebSocketUrl = undefined;
|
|
702
|
+
log.info(`[${caller}] : Tearing down Mobius WebSocket after registration error - serverType: ${serverType}`, loggerContext);
|
|
703
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
704
|
+
code: 3050,
|
|
705
|
+
reason: 'done (permanent)',
|
|
706
|
+
});
|
|
707
|
+
log.log(`[${caller}] : Mobius WebSocket disconnect complete after registration error - serverType: ${serverType}`, loggerContext);
|
|
708
|
+
}
|
|
573
709
|
if (abort) {
|
|
574
710
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
575
711
|
await uploadLogs();
|
|
@@ -584,25 +720,59 @@ export class Registration {
|
|
|
584
720
|
const RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
585
721
|
await this.mutex.runExclusive(async () => {
|
|
586
722
|
if (this.isDeviceRegistered()) {
|
|
587
|
-
const accessToken = await this.webex.credentials.getUserToken();
|
|
588
723
|
if (!this.webWorker) {
|
|
589
724
|
const blob = new Blob([webWorkerStr], { type: 'application/javascript' });
|
|
590
725
|
const blobUrl = URL.createObjectURL(blob);
|
|
591
|
-
|
|
726
|
+
const worker = new Worker(blobUrl);
|
|
727
|
+
this.webWorker = worker;
|
|
592
728
|
URL.revokeObjectURL(blobUrl);
|
|
593
|
-
|
|
729
|
+
worker.postMessage({
|
|
594
730
|
type: WorkerMessageType.START_KEEPALIVE,
|
|
595
|
-
accessToken: String(accessToken),
|
|
596
|
-
deviceUrl: String(this.webex.internal.device.url),
|
|
597
731
|
interval,
|
|
598
732
|
retryCountThreshold: RETRY_COUNT_THRESHOLD,
|
|
599
|
-
url,
|
|
600
733
|
});
|
|
601
|
-
|
|
734
|
+
const isCurrentWorker = () => this.webWorker === worker;
|
|
735
|
+
worker.onmessage = async (event) => {
|
|
602
736
|
const logContext = {
|
|
603
737
|
file: REGISTRATION_FILE,
|
|
604
738
|
method: KEEPALIVE_UTIL,
|
|
605
739
|
};
|
|
740
|
+
if (!isCurrentWorker()) {
|
|
741
|
+
log.info('Ignoring message from a replaced keepalive worker', logContext);
|
|
742
|
+
return;
|
|
743
|
+
}
|
|
744
|
+
if (event.data.type === WorkerMessageType.SEND_KEEPALIVE) {
|
|
745
|
+
try {
|
|
746
|
+
const res = await this.postKeepAlive(String(this.webex.internal.device.url), url);
|
|
747
|
+
if (!isCurrentWorker()) {
|
|
748
|
+
log.info('Discarding keepalive result of a replaced worker', logContext);
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
worker.postMessage({
|
|
752
|
+
type: WorkerMessageType.KEEPALIVE_RESULT,
|
|
753
|
+
statusCode: res.statusCode,
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
catch (err) {
|
|
757
|
+
const error = {
|
|
758
|
+
headers: {
|
|
759
|
+
trackingid: err.headers?.trackingid,
|
|
760
|
+
'retry-after': err.headers['retry-after'],
|
|
761
|
+
},
|
|
762
|
+
statusCode: err.statusCode,
|
|
763
|
+
statusText: err.statusText,
|
|
764
|
+
type: err.type,
|
|
765
|
+
};
|
|
766
|
+
if (!isCurrentWorker()) {
|
|
767
|
+
log.info(`Discarding keepalive failure of a replaced worker, status -> ${error.statusCode}`, logContext);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
worker.postMessage({
|
|
771
|
+
type: WorkerMessageType.KEEPALIVE_RESULT,
|
|
772
|
+
err: error,
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
}
|
|
606
776
|
if (event.data.type === WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
607
777
|
log.info(`Sent Keepalive, status: ${event.data.statusCode}`, logContext);
|
|
608
778
|
this.lineEmitter(LINE_EVENTS.RECONNECTED);
|
|
@@ -610,12 +780,18 @@ export class Registration {
|
|
|
610
780
|
if (event.data.type === WorkerMessageType.KEEPALIVE_FAILURE) {
|
|
611
781
|
const error = event.data.err;
|
|
612
782
|
log.warn(`Keep-alive missed ${event.data.keepAliveRetryCount} times. Status -> ${error.statusCode} `, logContext);
|
|
613
|
-
const abort = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
783
|
+
const { finalError: abort } = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
614
784
|
if (finalError) {
|
|
615
785
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
616
786
|
}
|
|
617
787
|
this.metricManager.submitRegistrationMetric(METRIC_EVENT.KEEPALIVE_ERROR, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, KEEPALIVE_UTIL, serverType, error.headers?.trackingid ?? '', event.data.keepAliveRetryCount, clientError);
|
|
618
|
-
}, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE },
|
|
788
|
+
}, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE }, {
|
|
789
|
+
retry429Cb: (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller),
|
|
790
|
+
sessionSupersededCb: (clientError) => this.handle409KeepaliveFailure(clientError, error, serverType, event.data.keepAliveRetryCount),
|
|
791
|
+
});
|
|
792
|
+
if (abort && Number(error.statusCode) === ERROR_CODE.CONFLICT) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
619
795
|
if (abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD) {
|
|
620
796
|
this.failoverImmediately = this.isCCFlow;
|
|
621
797
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
@@ -649,19 +825,25 @@ export class Registration {
|
|
|
649
825
|
isReconnectPending() {
|
|
650
826
|
return this.reconnectPending;
|
|
651
827
|
}
|
|
652
|
-
async deregister() {
|
|
828
|
+
async deregister(closeMobiusWss = false) {
|
|
829
|
+
const loggerContext = {
|
|
830
|
+
file: REGISTRATION_FILE,
|
|
831
|
+
method: METHODS.DEREGISTER,
|
|
832
|
+
};
|
|
833
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
653
834
|
try {
|
|
654
835
|
await this.deleteRegistration(this.activeMobiusUrl, this.deviceInfo.device?.deviceId, this.deviceInfo.device?.clientDeviceUri);
|
|
655
|
-
log.log('Registration successfully deregistered',
|
|
656
|
-
file: REGISTRATION_FILE,
|
|
657
|
-
method: METHODS.DEREGISTER,
|
|
658
|
-
});
|
|
836
|
+
log.log('Registration successfully deregistered', loggerContext);
|
|
659
837
|
}
|
|
660
838
|
catch (err) {
|
|
661
|
-
log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`,
|
|
662
|
-
|
|
663
|
-
|
|
839
|
+
log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`, loggerContext);
|
|
840
|
+
}
|
|
841
|
+
if (closeMobiusWss) {
|
|
842
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
843
|
+
code: 3050,
|
|
844
|
+
reason: 'done (permanent)',
|
|
664
845
|
});
|
|
846
|
+
log.log('Mobius socket disconnect complete after deregistration', loggerContext);
|
|
665
847
|
}
|
|
666
848
|
this.clearKeepaliveTimer();
|
|
667
849
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
@@ -683,7 +865,11 @@ export class Registration {
|
|
|
683
865
|
rehomingIntervalMin: DEFAULT_REHOMING_INTERVAL_MIN,
|
|
684
866
|
};
|
|
685
867
|
const stringToReplace = `${DEVICES_ENDPOINT_RESOURCE}/${restoreData.devices[0].deviceId}`;
|
|
686
|
-
|
|
868
|
+
let uri = restoreData.devices[0].uri.replace(stringToReplace, '');
|
|
869
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
870
|
+
uri = uri.replace('https://', 'wss://');
|
|
871
|
+
uri = !uri.endsWith('/') ? `${uri}/` : uri;
|
|
872
|
+
}
|
|
687
873
|
this.setActiveMobiusUrl(uri);
|
|
688
874
|
this.registrationStatus = RegistrationStatus.ACTIVE;
|
|
689
875
|
return true;
|
|
@@ -709,5 +895,48 @@ export class Registration {
|
|
|
709
895
|
}
|
|
710
896
|
}
|
|
711
897
|
}
|
|
898
|
+
async handleRegistrationDownEvent(event) {
|
|
899
|
+
const loggerContext = {
|
|
900
|
+
file: REGISTRATION_FILE,
|
|
901
|
+
method: METHODS.HANDLE_REGISTRATION_DOWN_EVENT,
|
|
902
|
+
};
|
|
903
|
+
log.info(`Registration down received - trackingId: ${event?.trackingId ?? 'unknown'}, eventId: ${event?.eventId ?? 'unknown'}`, loggerContext);
|
|
904
|
+
const [activeCall] = Object.values(this.callManager.getActiveCalls());
|
|
905
|
+
activeCall?.end();
|
|
906
|
+
await this.registrationCleanup(METHODS.HANDLE_REGISTRATION_DOWN_EVENT, {
|
|
907
|
+
reason: HARD_STOP_REASON.REGISTRATION_DOWN,
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
async registrationCleanup(caller, hardStop) {
|
|
911
|
+
const loggerContext = {
|
|
912
|
+
file: REGISTRATION_FILE,
|
|
913
|
+
method: caller,
|
|
914
|
+
};
|
|
915
|
+
log.info(`[${caller}] : Running ${hardStop.reason} cleanup`, loggerContext);
|
|
916
|
+
await this.mutex.runExclusive(async () => {
|
|
917
|
+
this.clearFailbackTimer();
|
|
918
|
+
this.clearKeepaliveTimer();
|
|
919
|
+
this.reconnectPending = false;
|
|
920
|
+
this.scheduled429Retry = false;
|
|
921
|
+
this.failoverImmediately = false;
|
|
922
|
+
this.retryAfter = undefined;
|
|
923
|
+
this.registerRetry = false;
|
|
924
|
+
this.clearFailoverState();
|
|
925
|
+
this.setStatus(RegistrationStatus.INACTIVE);
|
|
926
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
927
|
+
try {
|
|
928
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
929
|
+
code: 3050,
|
|
930
|
+
reason: 'done (permanent)',
|
|
931
|
+
});
|
|
932
|
+
log.log(`Mobius socket disconnect complete after ${hardStop.reason}`, loggerContext);
|
|
933
|
+
}
|
|
934
|
+
catch (err) {
|
|
935
|
+
log.warn(`Mobius socket disconnect failed after ${hardStop.reason}: ${String(err)}`, loggerContext);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
this.lineEmitter(LINE_EVENTS.UNREGISTERED, undefined, hardStop.error);
|
|
939
|
+
});
|
|
940
|
+
}
|
|
712
941
|
}
|
|
713
942
|
export const createRegistration = (webex, serviceData, mutex, lineEmitter, logLevel, jwe) => new Registration(webex, serviceData, mutex, lineEmitter, logLevel, jwe);
|