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