@webex/calling 3.12.0-next.9 → 3.12.0-next.91
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 +456 -226
- package/dist/CallingClient/CallingClient.js.map +1 -1
- package/dist/CallingClient/CallingClient.test.js +513 -154
- package/dist/CallingClient/CallingClient.test.js.map +1 -1
- package/dist/CallingClient/calling/call.js +634 -454
- package/dist/CallingClient/calling/call.js.map +1 -1
- package/dist/CallingClient/calling/call.test.js +809 -451
- 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 +890 -497
- package/dist/CallingClient/registration/register.js.map +1 -1
- package/dist/CallingClient/registration/register.test.js +649 -58
- 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 +212 -71
- package/dist/common/Utils.js.map +1 -1
- package/dist/common/Utils.test.js +417 -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 +126 -10
- package/dist/module/CallingClient/calling/call.js +198 -66
- 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 +266 -64
- 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 +85 -22
- 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 +8 -1
- package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
- package/dist/types/CallingClient/registration/types.d.ts +27 -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 +21 -5
- 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,12 @@ 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 { APIRequest } from '../utils/request';
|
|
13
14
|
export class Registration {
|
|
14
15
|
sdkConnector;
|
|
15
16
|
webex;
|
|
@@ -36,6 +37,7 @@ export class Registration {
|
|
|
36
37
|
retryAfter;
|
|
37
38
|
scheduled429Retry = false;
|
|
38
39
|
webWorker;
|
|
40
|
+
apiRequest;
|
|
39
41
|
constructor(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
|
|
40
42
|
this.jwe = jwe;
|
|
41
43
|
this.sdkConnector = SDKConnector;
|
|
@@ -57,6 +59,12 @@ export class Registration {
|
|
|
57
59
|
this.lineEmitter = lineEmitter;
|
|
58
60
|
this.primaryMobiusUris = [];
|
|
59
61
|
this.backupMobiusUris = [];
|
|
62
|
+
this.apiRequest = APIRequest.getInstance({ webex: this.webex });
|
|
63
|
+
}
|
|
64
|
+
getServerType(url) {
|
|
65
|
+
return ((this.primaryMobiusUris.includes(url) && 'PRIMARY') ||
|
|
66
|
+
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
67
|
+
'UNKNOWN');
|
|
60
68
|
}
|
|
61
69
|
getFailoverCacheKey() {
|
|
62
70
|
return `${FAILOVER_CACHE_PREFIX}.${this.userId || 'unknown'}`;
|
|
@@ -131,16 +139,22 @@ export class Registration {
|
|
|
131
139
|
}
|
|
132
140
|
async deleteRegistration(url, deviceId, deviceUrl) {
|
|
133
141
|
let response;
|
|
142
|
+
const requestObj = {
|
|
143
|
+
uri: `${url}${DEVICES_ENDPOINT_RESOURCE}/${deviceId}`,
|
|
144
|
+
method: HTTP_METHODS.DELETE,
|
|
145
|
+
headers: {
|
|
146
|
+
[CISCO_DEVICE_URL]: deviceUrl,
|
|
147
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
148
|
+
},
|
|
149
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
150
|
+
};
|
|
151
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
152
|
+
requestObj.body = {
|
|
153
|
+
deviceId,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
134
156
|
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
|
-
});
|
|
157
|
+
response = await this.apiRequest.makeRequest(requestObj);
|
|
144
158
|
}
|
|
145
159
|
catch (error) {
|
|
146
160
|
log.warn(`Delete failed with Mobius: ${JSON.stringify(error)}`, {
|
|
@@ -151,7 +165,7 @@ export class Registration {
|
|
|
151
165
|
}
|
|
152
166
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
153
167
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
154
|
-
return response
|
|
168
|
+
return response;
|
|
155
169
|
}
|
|
156
170
|
async postRegistration(url) {
|
|
157
171
|
const deviceInfo = {
|
|
@@ -159,7 +173,7 @@ export class Registration {
|
|
|
159
173
|
clientDeviceUri: this.webex.internal.device.url,
|
|
160
174
|
serviceData: this.jwe ? { ...this.serviceData, jwe: this.jwe } : this.serviceData,
|
|
161
175
|
};
|
|
162
|
-
return this.
|
|
176
|
+
return this.apiRequest.makeRequest({
|
|
163
177
|
uri: `${url}device`,
|
|
164
178
|
method: HTTP_METHODS.POST,
|
|
165
179
|
headers: {
|
|
@@ -171,7 +185,23 @@ export class Registration {
|
|
|
171
185
|
});
|
|
172
186
|
}
|
|
173
187
|
async restorePreviousRegistration(caller) {
|
|
188
|
+
const loggerContext = {
|
|
189
|
+
file: REGISTRATION_FILE,
|
|
190
|
+
method: METHODS.RESTORE_PREVIOUS_REGISTRATION,
|
|
191
|
+
};
|
|
192
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}, activeMobiusUrl: ${this.activeMobiusUrl}`, loggerContext);
|
|
174
193
|
let abort = false;
|
|
194
|
+
if (this.apiRequest.isSocketEnabled() &&
|
|
195
|
+
`${this.apiRequest.getConnectedWebSocketUrl()}/` !== this.activeMobiusUrl) {
|
|
196
|
+
log.info(`Disconnecting from Mobius socket to restore previous registration.`, {
|
|
197
|
+
file: REGISTRATION_FILE,
|
|
198
|
+
method: 'restorePreviousRegistration',
|
|
199
|
+
});
|
|
200
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
201
|
+
code: 3050,
|
|
202
|
+
reason: 'done (permanent)',
|
|
203
|
+
});
|
|
204
|
+
}
|
|
175
205
|
if (this.activeMobiusUrl) {
|
|
176
206
|
abort = await this.attemptRegistrationWithServers(caller, [this.activeMobiusUrl]);
|
|
177
207
|
if (this.retryAfter) {
|
|
@@ -185,22 +215,47 @@ export class Registration {
|
|
|
185
215
|
abort = await this.attemptRegistrationWithServers(caller, this.backupMobiusUris);
|
|
186
216
|
}
|
|
187
217
|
else {
|
|
188
|
-
this.restartRegistration(caller);
|
|
218
|
+
await this.restartRegistration(caller);
|
|
189
219
|
}
|
|
190
220
|
this.retryAfter = undefined;
|
|
221
|
+
log.log(`restorePreviousRegistration completed via 429 retry-after path - caller: ${caller}`, loggerContext);
|
|
191
222
|
return true;
|
|
192
223
|
}
|
|
193
224
|
}
|
|
225
|
+
log.log(`restorePreviousRegistration completed - caller: ${caller}, deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
194
226
|
return abort;
|
|
195
227
|
}
|
|
196
228
|
async handle404KeepaliveFailure(caller) {
|
|
229
|
+
const loggerContext = {
|
|
230
|
+
file: REGISTRATION_FILE,
|
|
231
|
+
method: METHODS.HANDLE_404_KEEPALIVE_FAILURE,
|
|
232
|
+
};
|
|
233
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}`, loggerContext);
|
|
197
234
|
if (caller === KEEPALIVE_UTIL) {
|
|
198
235
|
const abort = await this.attemptRegistrationWithServers(caller);
|
|
199
236
|
if (!abort && !this.isDeviceRegistered()) {
|
|
237
|
+
log.warn('Keepalive 404 recovery: re-registration did not complete, starting failover timer', loggerContext);
|
|
200
238
|
await this.startFailoverTimer();
|
|
201
239
|
}
|
|
240
|
+
else {
|
|
241
|
+
log.log(`Keepalive 404 recovery handled - deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
242
|
+
}
|
|
202
243
|
}
|
|
203
244
|
}
|
|
245
|
+
async handle409KeepaliveFailure(lineError, error, serverType, keepaliveRetryCount) {
|
|
246
|
+
const loggerContext = {
|
|
247
|
+
file: REGISTRATION_FILE,
|
|
248
|
+
method: METHODS.HANDLE_409_KEEPALIVE_FAILURE,
|
|
249
|
+
};
|
|
250
|
+
log.warn(`Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ${keepaliveRetryCount}`, loggerContext);
|
|
251
|
+
this.clearKeepaliveTimer();
|
|
252
|
+
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);
|
|
253
|
+
await this.registrationCleanup(METHODS.HANDLE_409_KEEPALIVE_FAILURE, {
|
|
254
|
+
reason: HARD_STOP_REASON.SESSION_SUPERSEDED,
|
|
255
|
+
error: lineError,
|
|
256
|
+
});
|
|
257
|
+
await uploadLogs();
|
|
258
|
+
}
|
|
204
259
|
async handle429Retry(retryAfter, caller) {
|
|
205
260
|
if (caller === FAILBACK_UTIL) {
|
|
206
261
|
if (this.failback429RetryAttempts >= REG_FAILBACK_429_MAX_RETRIES) {
|
|
@@ -228,7 +283,7 @@ export class Registration {
|
|
|
228
283
|
method: REG_429_RETRY_UTIL,
|
|
229
284
|
});
|
|
230
285
|
await this.startKeepaliveTimer(this.deviceInfo.device?.uri, this.deviceInfo.keepaliveInterval, 'UNKNOWN');
|
|
231
|
-
}, retryAfter * 1000);
|
|
286
|
+
}, (retryAfter - Number(this.deviceInfo.keepaliveInterval || 0)) * 1000);
|
|
232
287
|
}
|
|
233
288
|
else {
|
|
234
289
|
this.retryAfter = retryAfter;
|
|
@@ -279,6 +334,14 @@ export class Registration {
|
|
|
279
334
|
log.log(`Scheduled retry with primary in ${interval} seconds, number of attempts : ${attempt}`, loggerContext);
|
|
280
335
|
}
|
|
281
336
|
else if (this.backupMobiusUris.length) {
|
|
337
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
338
|
+
log.info('Disconnecting from primary Mobius socket for failover to backup servers', loggerContext);
|
|
339
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
340
|
+
code: 3050,
|
|
341
|
+
reason: 'done (permanent)',
|
|
342
|
+
});
|
|
343
|
+
log.log('Mobius socket disconnect complete prior to backup failover', loggerContext);
|
|
344
|
+
}
|
|
282
345
|
this.saveFailoverState({
|
|
283
346
|
attempt,
|
|
284
347
|
timeElapsed,
|
|
@@ -311,7 +374,7 @@ export class Registration {
|
|
|
311
374
|
await uploadLogs();
|
|
312
375
|
emitFinalFailure((clientError) => {
|
|
313
376
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
314
|
-
}, loggerContext);
|
|
377
|
+
}, loggerContext, interval < 0 ? 'Timer threshold exceeded during failover' : undefined);
|
|
315
378
|
}
|
|
316
379
|
}
|
|
317
380
|
clearFailbackTimer() {
|
|
@@ -320,11 +383,25 @@ export class Registration {
|
|
|
320
383
|
this.failbackTimer = undefined;
|
|
321
384
|
}
|
|
322
385
|
}
|
|
386
|
+
async postKeepAlive(deviceUrl, url) {
|
|
387
|
+
return this.apiRequest.makeRequest({
|
|
388
|
+
uri: `${url}/status`,
|
|
389
|
+
method: HTTP_METHODS.POST,
|
|
390
|
+
headers: {
|
|
391
|
+
[CISCO_DEVICE_URL]: deviceUrl,
|
|
392
|
+
[SPARK_USER_AGENT]: CALLING_USER_AGENT,
|
|
393
|
+
},
|
|
394
|
+
body: {
|
|
395
|
+
deviceId: this.deviceInfo.device?.deviceId,
|
|
396
|
+
},
|
|
397
|
+
service: ALLOWED_SERVICES.MOBIUS,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
323
400
|
async isPrimaryActive() {
|
|
324
401
|
let status;
|
|
325
402
|
for (const mobiusUrl of this.primaryMobiusUris) {
|
|
326
403
|
try {
|
|
327
|
-
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/');
|
|
404
|
+
const baseUri = mobiusUrl.replace(URL_ENDPOINT, '/').replace('wss://', 'https://');
|
|
328
405
|
const response = await this.webex.request({
|
|
329
406
|
uri: `${baseUri}ping`,
|
|
330
407
|
method: HTTP_METHODS.GET,
|
|
@@ -362,14 +439,23 @@ export class Registration {
|
|
|
362
439
|
this.rehomingIntervalMin);
|
|
363
440
|
}
|
|
364
441
|
initiateFailback() {
|
|
442
|
+
const loggerContext = {
|
|
443
|
+
file: REGISTRATION_FILE,
|
|
444
|
+
method: METHODS.INITIATE_FAILBACK,
|
|
445
|
+
};
|
|
365
446
|
if (this.isFailbackRequired()) {
|
|
366
447
|
if (!this.failbackTimer) {
|
|
367
448
|
this.failback429RetryAttempts = 0;
|
|
368
449
|
const intervalInMinutes = this.getFailbackInterval();
|
|
450
|
+
log.info(`Scheduling failback to primary - intervalMinutes: ${intervalInMinutes}`, loggerContext);
|
|
369
451
|
this.startFailbackTimer(intervalInMinutes * MINUTES_TO_SEC_MFACTOR);
|
|
370
452
|
}
|
|
453
|
+
else {
|
|
454
|
+
log.info('Failback timer already scheduled, skipping', loggerContext);
|
|
455
|
+
}
|
|
371
456
|
}
|
|
372
457
|
else {
|
|
458
|
+
log.info('Failback not required, clearing any pending failback timer', loggerContext);
|
|
373
459
|
this.failback429RetryAttempts = 0;
|
|
374
460
|
this.clearFailbackTimer();
|
|
375
461
|
}
|
|
@@ -382,15 +468,25 @@ export class Registration {
|
|
|
382
468
|
});
|
|
383
469
|
}
|
|
384
470
|
async executeFailback() {
|
|
471
|
+
const loggerContext = {
|
|
472
|
+
file: REGISTRATION_FILE,
|
|
473
|
+
method: METHODS.EXECUTE_FAILBACK,
|
|
474
|
+
};
|
|
475
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
385
476
|
await this.mutex.runExclusive(async () => {
|
|
386
477
|
if (this.isFailbackRequired()) {
|
|
387
478
|
const primaryServerStatus = await this.isPrimaryActive();
|
|
388
479
|
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
|
-
});
|
|
480
|
+
log.info(`Attempting failback to primary.`, loggerContext);
|
|
393
481
|
await this.deregister();
|
|
482
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
483
|
+
log.info('Disconnecting from backup Mobius socket for failback to primary', loggerContext);
|
|
484
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
485
|
+
code: 3050,
|
|
486
|
+
reason: 'done (permanent)',
|
|
487
|
+
});
|
|
488
|
+
log.log('Mobius socket disconnect complete prior to primary failback', loggerContext);
|
|
489
|
+
}
|
|
394
490
|
const abort = await this.attemptRegistrationWithServers(FAILBACK_UTIL);
|
|
395
491
|
if (this.scheduled429Retry || abort || this.isDeviceRegistered()) {
|
|
396
492
|
return;
|
|
@@ -401,7 +497,7 @@ export class Registration {
|
|
|
401
497
|
return;
|
|
402
498
|
}
|
|
403
499
|
if (!this.isDeviceRegistered()) {
|
|
404
|
-
await this.restartRegistration(
|
|
500
|
+
await this.restartRegistration(loggerContext.method);
|
|
405
501
|
}
|
|
406
502
|
else {
|
|
407
503
|
this.failbackTimer = undefined;
|
|
@@ -409,10 +505,7 @@ export class Registration {
|
|
|
409
505
|
}
|
|
410
506
|
}
|
|
411
507
|
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
|
-
});
|
|
508
|
+
log.info('Active calls present or primary Mobius is down, deferring failback to next cycle.', loggerContext);
|
|
416
509
|
this.failbackTimer = undefined;
|
|
417
510
|
this.initiateFailback();
|
|
418
511
|
}
|
|
@@ -442,12 +535,18 @@ export class Registration {
|
|
|
442
535
|
this.registrationStatus = value;
|
|
443
536
|
}
|
|
444
537
|
async restartRegistration(caller) {
|
|
538
|
+
const loggerContext = {
|
|
539
|
+
file: REGISTRATION_FILE,
|
|
540
|
+
method: METHODS.RESTART_REGISTRATION,
|
|
541
|
+
};
|
|
542
|
+
log.info(`${METHOD_START_MESSAGE} - caller: ${caller}`, loggerContext);
|
|
445
543
|
this.clearFailbackTimer();
|
|
446
544
|
this.failback429RetryAttempts = 0;
|
|
447
545
|
const abort = await this.attemptRegistrationWithServers(caller, this.primaryMobiusUris);
|
|
448
546
|
if (!abort && !this.isDeviceRegistered()) {
|
|
449
547
|
await this.startFailoverTimer();
|
|
450
548
|
}
|
|
549
|
+
log.log(`restartRegistration completed - caller: ${caller}, deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
451
550
|
}
|
|
452
551
|
async handleConnectionRestoration(retry) {
|
|
453
552
|
log.info(METHOD_START_MESSAGE, {
|
|
@@ -500,7 +599,13 @@ export class Registration {
|
|
|
500
599
|
};
|
|
501
600
|
}
|
|
502
601
|
async triggerRegistration() {
|
|
602
|
+
const loggerContext = {
|
|
603
|
+
file: REGISTRATION_FILE,
|
|
604
|
+
method: METHODS.TRIGGER_REGISTRATION,
|
|
605
|
+
};
|
|
606
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
503
607
|
if (await this.resumeFailover()) {
|
|
608
|
+
log.info('Registration trigger handled by resumeFailover path', loggerContext);
|
|
504
609
|
return;
|
|
505
610
|
}
|
|
506
611
|
if (this.primaryMobiusUris.length > 0) {
|
|
@@ -508,43 +613,51 @@ export class Registration {
|
|
|
508
613
|
if (!this.isDeviceRegistered() && !abort) {
|
|
509
614
|
await this.startFailoverTimer();
|
|
510
615
|
}
|
|
616
|
+
log.log(`triggerRegistration completed - deviceRegistered: ${this.isDeviceRegistered()}, abort: ${abort}`, loggerContext);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
log.warn('triggerRegistration skipped: no primary Mobius URIs available', loggerContext);
|
|
511
620
|
}
|
|
512
621
|
}
|
|
513
622
|
async attemptRegistrationWithServers(caller, servers = this.primaryMobiusUris) {
|
|
623
|
+
const loggerContext = {
|
|
624
|
+
file: REGISTRATION_FILE,
|
|
625
|
+
method: REGISTER_UTIL,
|
|
626
|
+
};
|
|
514
627
|
let abort = false;
|
|
515
628
|
this.retryAfter = undefined;
|
|
629
|
+
let connectedWebSocketUrl;
|
|
516
630
|
if (this.failoverImmediately) {
|
|
517
631
|
return abort;
|
|
518
632
|
}
|
|
519
633
|
if (this.isDeviceRegistered()) {
|
|
520
|
-
log.info(`[${caller}] : Device already registered with : ${this.activeMobiusUrl}`,
|
|
521
|
-
file: REGISTRATION_FILE,
|
|
522
|
-
method: REGISTER_UTIL,
|
|
523
|
-
});
|
|
634
|
+
log.info(`[${caller}] : Device already registered with : ${this.activeMobiusUrl}`, loggerContext);
|
|
524
635
|
return abort;
|
|
525
636
|
}
|
|
637
|
+
if (servers.length) {
|
|
638
|
+
this.apiRequest.setSocketEnabled(servers[0].startsWith('wss://'));
|
|
639
|
+
}
|
|
526
640
|
for (const url of servers) {
|
|
527
|
-
const serverType =
|
|
528
|
-
(this.backupMobiusUris?.includes(url) && 'BACKUP') ||
|
|
529
|
-
'UNKNOWN';
|
|
641
|
+
const serverType = this.getServerType(url);
|
|
530
642
|
try {
|
|
531
643
|
abort = false;
|
|
532
644
|
this.registrationStatus = RegistrationStatus.INACTIVE;
|
|
533
645
|
this.lineEmitter(LINE_EVENTS.CONNECTING);
|
|
534
|
-
log.info(`[${caller}] : Mobius url to contact: ${url}`,
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
646
|
+
log.info(`[${caller}] : Mobius url to contact: ${url}`, loggerContext);
|
|
647
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
648
|
+
const wssNormalizedUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
649
|
+
log.info(`[${caller}] : Connecting to Mobius WebSocket - serverType: ${serverType}, wssUrl: ${wssNormalizedUrl}`, loggerContext);
|
|
650
|
+
connectedWebSocketUrl = await this.apiRequest.connectToMobiusSocket(wssNormalizedUrl);
|
|
651
|
+
connectedWebSocketUrl = connectedWebSocketUrl ? `${connectedWebSocketUrl}/` : undefined;
|
|
652
|
+
log.log(`[${caller}] : Mobius WebSocket connected - serverType: ${serverType}, connectedWebSocketUrl: ${connectedWebSocketUrl}`, loggerContext);
|
|
653
|
+
}
|
|
538
654
|
const resp = await this.postRegistration(url);
|
|
539
655
|
this.clearFailoverState();
|
|
540
656
|
this.deviceInfo = resp.body;
|
|
541
657
|
this.registrationStatus = RegistrationStatus.ACTIVE;
|
|
542
|
-
this.setActiveMobiusUrl(url);
|
|
658
|
+
this.setActiveMobiusUrl(connectedWebSocketUrl || url);
|
|
543
659
|
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
|
-
});
|
|
660
|
+
log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId} responseTrackingId: ${resp.headers?.trackingid}`, loggerContext);
|
|
548
661
|
this.setIntervalValues(this.deviceInfo);
|
|
549
662
|
this.metricManager.setDeviceInfo(this.deviceInfo);
|
|
550
663
|
this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, resp.headers?.trackingid ?? '', undefined, undefined);
|
|
@@ -554,22 +667,32 @@ export class Registration {
|
|
|
554
667
|
}
|
|
555
668
|
catch (err) {
|
|
556
669
|
const body = err;
|
|
557
|
-
|
|
558
|
-
if (
|
|
670
|
+
const { finalError, shouldDisconnect } = await handleRegistrationErrors(body, (clientError, isFinalError) => {
|
|
671
|
+
if (isFinalError) {
|
|
559
672
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
560
673
|
}
|
|
561
674
|
else {
|
|
562
675
|
this.lineEmitter(LINE_EVENTS.UNREGISTERED);
|
|
563
676
|
}
|
|
564
677
|
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 },
|
|
678
|
+
}, { method: caller, file: REGISTRATION_FILE }, {
|
|
679
|
+
retry429Cb: (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller),
|
|
680
|
+
restoreRegCb: this.restoreRegistrationCallBack(),
|
|
681
|
+
}, servers.length);
|
|
682
|
+
abort = finalError;
|
|
566
683
|
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
|
-
});
|
|
684
|
+
log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`, loggerContext);
|
|
571
685
|
break;
|
|
572
686
|
}
|
|
687
|
+
if (shouldDisconnect && this.apiRequest.isSocketEnabled()) {
|
|
688
|
+
connectedWebSocketUrl = undefined;
|
|
689
|
+
log.info(`[${caller}] : Tearing down Mobius WebSocket after registration error - serverType: ${serverType}`, loggerContext);
|
|
690
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
691
|
+
code: 3050,
|
|
692
|
+
reason: 'done (permanent)',
|
|
693
|
+
});
|
|
694
|
+
log.log(`[${caller}] : Mobius WebSocket disconnect complete after registration error - serverType: ${serverType}`, loggerContext);
|
|
695
|
+
}
|
|
573
696
|
if (abort) {
|
|
574
697
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
575
698
|
await uploadLogs();
|
|
@@ -584,7 +707,6 @@ export class Registration {
|
|
|
584
707
|
const RETRY_COUNT_THRESHOLD = this.isCCFlow ? 4 : 5;
|
|
585
708
|
await this.mutex.runExclusive(async () => {
|
|
586
709
|
if (this.isDeviceRegistered()) {
|
|
587
|
-
const accessToken = await this.webex.credentials.getUserToken();
|
|
588
710
|
if (!this.webWorker) {
|
|
589
711
|
const blob = new Blob([webWorkerStr], { type: 'application/javascript' });
|
|
590
712
|
const blobUrl = URL.createObjectURL(blob);
|
|
@@ -592,17 +714,38 @@ export class Registration {
|
|
|
592
714
|
URL.revokeObjectURL(blobUrl);
|
|
593
715
|
this.webWorker.postMessage({
|
|
594
716
|
type: WorkerMessageType.START_KEEPALIVE,
|
|
595
|
-
accessToken: String(accessToken),
|
|
596
|
-
deviceUrl: String(this.webex.internal.device.url),
|
|
597
717
|
interval,
|
|
598
718
|
retryCountThreshold: RETRY_COUNT_THRESHOLD,
|
|
599
|
-
url,
|
|
600
719
|
});
|
|
601
720
|
this.webWorker.onmessage = async (event) => {
|
|
602
721
|
const logContext = {
|
|
603
722
|
file: REGISTRATION_FILE,
|
|
604
723
|
method: KEEPALIVE_UTIL,
|
|
605
724
|
};
|
|
725
|
+
if (event.data.type === WorkerMessageType.SEND_KEEPALIVE) {
|
|
726
|
+
try {
|
|
727
|
+
const res = await this.postKeepAlive(String(this.webex.internal.device.url), url);
|
|
728
|
+
this.webWorker?.postMessage({
|
|
729
|
+
type: WorkerMessageType.KEEPALIVE_RESULT,
|
|
730
|
+
statusCode: res.statusCode,
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
catch (err) {
|
|
734
|
+
const error = {
|
|
735
|
+
headers: {
|
|
736
|
+
trackingid: err.headers?.trackingid,
|
|
737
|
+
'retry-after': err.headers['retry-after'],
|
|
738
|
+
},
|
|
739
|
+
statusCode: err.statusCode,
|
|
740
|
+
statusText: err.statusText,
|
|
741
|
+
type: err.type,
|
|
742
|
+
};
|
|
743
|
+
this.webWorker?.postMessage({
|
|
744
|
+
type: WorkerMessageType.KEEPALIVE_RESULT,
|
|
745
|
+
err: error,
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
606
749
|
if (event.data.type === WorkerMessageType.KEEPALIVE_SUCCESS) {
|
|
607
750
|
log.info(`Sent Keepalive, status: ${event.data.statusCode}`, logContext);
|
|
608
751
|
this.lineEmitter(LINE_EVENTS.RECONNECTED);
|
|
@@ -610,12 +753,18 @@ export class Registration {
|
|
|
610
753
|
if (event.data.type === WorkerMessageType.KEEPALIVE_FAILURE) {
|
|
611
754
|
const error = event.data.err;
|
|
612
755
|
log.warn(`Keep-alive missed ${event.data.keepAliveRetryCount} times. Status -> ${error.statusCode} `, logContext);
|
|
613
|
-
const abort = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
756
|
+
const { finalError: abort, handledByCallback } = await handleRegistrationErrors(error, (clientError, finalError) => {
|
|
614
757
|
if (finalError) {
|
|
615
758
|
this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
|
|
616
759
|
}
|
|
617
760
|
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 },
|
|
761
|
+
}, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE }, {
|
|
762
|
+
retry429Cb: (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller),
|
|
763
|
+
sessionSupersededCb: (clientError) => this.handle409KeepaliveFailure(clientError, error, serverType, event.data.keepAliveRetryCount),
|
|
764
|
+
});
|
|
765
|
+
if (handledByCallback) {
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
619
768
|
if (abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD) {
|
|
620
769
|
this.failoverImmediately = this.isCCFlow;
|
|
621
770
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
@@ -649,19 +798,25 @@ export class Registration {
|
|
|
649
798
|
isReconnectPending() {
|
|
650
799
|
return this.reconnectPending;
|
|
651
800
|
}
|
|
652
|
-
async deregister() {
|
|
801
|
+
async deregister(closeMobiusWss = false) {
|
|
802
|
+
const loggerContext = {
|
|
803
|
+
file: REGISTRATION_FILE,
|
|
804
|
+
method: METHODS.DEREGISTER,
|
|
805
|
+
};
|
|
806
|
+
log.info(METHOD_START_MESSAGE, loggerContext);
|
|
653
807
|
try {
|
|
654
808
|
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
|
-
});
|
|
809
|
+
log.log('Registration successfully deregistered', loggerContext);
|
|
659
810
|
}
|
|
660
811
|
catch (err) {
|
|
661
|
-
log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`,
|
|
662
|
-
|
|
663
|
-
|
|
812
|
+
log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`, loggerContext);
|
|
813
|
+
}
|
|
814
|
+
if (closeMobiusWss) {
|
|
815
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
816
|
+
code: 3050,
|
|
817
|
+
reason: 'done (permanent)',
|
|
664
818
|
});
|
|
819
|
+
log.log('Mobius socket disconnect complete after deregistration', loggerContext);
|
|
665
820
|
}
|
|
666
821
|
this.clearKeepaliveTimer();
|
|
667
822
|
this.setStatus(RegistrationStatus.INACTIVE);
|
|
@@ -683,7 +838,11 @@ export class Registration {
|
|
|
683
838
|
rehomingIntervalMin: DEFAULT_REHOMING_INTERVAL_MIN,
|
|
684
839
|
};
|
|
685
840
|
const stringToReplace = `${DEVICES_ENDPOINT_RESOURCE}/${restoreData.devices[0].deviceId}`;
|
|
686
|
-
|
|
841
|
+
let uri = restoreData.devices[0].uri.replace(stringToReplace, '');
|
|
842
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
843
|
+
uri = uri.replace('https://', 'wss://');
|
|
844
|
+
uri = !uri.endsWith('/') ? `${uri}/` : uri;
|
|
845
|
+
}
|
|
687
846
|
this.setActiveMobiusUrl(uri);
|
|
688
847
|
this.registrationStatus = RegistrationStatus.ACTIVE;
|
|
689
848
|
return true;
|
|
@@ -709,5 +868,48 @@ export class Registration {
|
|
|
709
868
|
}
|
|
710
869
|
}
|
|
711
870
|
}
|
|
871
|
+
async handleRegistrationDownEvent(event) {
|
|
872
|
+
const loggerContext = {
|
|
873
|
+
file: REGISTRATION_FILE,
|
|
874
|
+
method: METHODS.HANDLE_REGISTRATION_DOWN_EVENT,
|
|
875
|
+
};
|
|
876
|
+
log.info(`Registration down received - trackingId: ${event?.trackingId ?? 'unknown'}, eventId: ${event?.eventId ?? 'unknown'}`, loggerContext);
|
|
877
|
+
const [activeCall] = Object.values(this.callManager.getActiveCalls());
|
|
878
|
+
activeCall?.end();
|
|
879
|
+
await this.registrationCleanup(METHODS.HANDLE_REGISTRATION_DOWN_EVENT, {
|
|
880
|
+
reason: HARD_STOP_REASON.REGISTRATION_DOWN,
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
async registrationCleanup(caller, hardStop) {
|
|
884
|
+
const loggerContext = {
|
|
885
|
+
file: REGISTRATION_FILE,
|
|
886
|
+
method: caller,
|
|
887
|
+
};
|
|
888
|
+
log.info(`[${caller}] : Running ${hardStop.reason} cleanup`, loggerContext);
|
|
889
|
+
await this.mutex.runExclusive(async () => {
|
|
890
|
+
this.clearFailbackTimer();
|
|
891
|
+
this.clearKeepaliveTimer();
|
|
892
|
+
this.reconnectPending = false;
|
|
893
|
+
this.scheduled429Retry = false;
|
|
894
|
+
this.failoverImmediately = false;
|
|
895
|
+
this.retryAfter = undefined;
|
|
896
|
+
this.registerRetry = false;
|
|
897
|
+
this.clearFailoverState();
|
|
898
|
+
this.setStatus(RegistrationStatus.INACTIVE);
|
|
899
|
+
if (this.apiRequest.isSocketEnabled()) {
|
|
900
|
+
try {
|
|
901
|
+
await this.apiRequest.disconnectFromMobiusSocket({
|
|
902
|
+
code: 3050,
|
|
903
|
+
reason: 'done (permanent)',
|
|
904
|
+
});
|
|
905
|
+
log.log(`Mobius socket disconnect complete after ${hardStop.reason}`, loggerContext);
|
|
906
|
+
}
|
|
907
|
+
catch (err) {
|
|
908
|
+
log.warn(`Mobius socket disconnect failed after ${hardStop.reason}: ${String(err)}`, loggerContext);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
this.lineEmitter(LINE_EVENTS.UNREGISTERED, undefined, hardStop.error);
|
|
912
|
+
});
|
|
913
|
+
}
|
|
712
914
|
}
|
|
713
915
|
export const createRegistration = (webex, serviceData, mutex, lineEmitter, logLevel, jwe) => new Registration(webex, serviceData, mutex, lineEmitter, logLevel, jwe);
|