@resolveio/server-lib 20.14.33 → 20.14.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resolveio/server-lib",
3
- "version": "20.14.33",
3
+ "version": "20.14.35",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "package": "./build_package.sh",
package/server-app.d.ts CHANGED
@@ -29,6 +29,21 @@ export declare class ResolveIOMainServer {
29
29
  private _workerServerManager;
30
30
  private _httpServerClosePromise;
31
31
  private _websocketServerClosePromise;
32
+ private _wsConnectDebug;
33
+ private _perfDebug;
34
+ private _perfDebugIntervalMs;
35
+ private _perfDebugTimer;
36
+ private _perfDebugLastCpu;
37
+ private _perfDebugLastTs;
38
+ private _eventLoopHistogram;
39
+ private _cpuProfileOnStart;
40
+ private _cpuProfileAuto;
41
+ private _cpuProfileDurationMs;
42
+ private _cpuProfileThresholdPct;
43
+ private _cpuProfileTriggerCount;
44
+ private _cpuProfileHighCount;
45
+ private _cpuProfileDir;
46
+ private _cpuProfileSession;
32
47
  private _serverStartTime;
33
48
  private _lastErrorMsg;
34
49
  private _debugMsgRecv;
@@ -68,6 +83,22 @@ export declare class ResolveIOMainServer {
68
83
  private decodeBufferPayload;
69
84
  private parseTextFallback;
70
85
  private looksLikeTextPayload;
86
+ private resolveConnectDebug;
87
+ private resolvePerfDebug;
88
+ private resolveCpuProfileOnStart;
89
+ private resolveCpuProfileAuto;
90
+ private resolveCpuProfileDurationMs;
91
+ private resolveCpuProfileThresholdPct;
92
+ private resolveCpuProfileTriggerCount;
93
+ private resolveCpuProfileDir;
94
+ private parsePositiveInt;
95
+ private parsePositiveFloat;
96
+ private startPerfDebug;
97
+ private startCpuProfile;
98
+ private stopCpuProfile;
99
+ private resolveWritableProfileDir;
100
+ private parseDebugFlag;
101
+ private logConnectDebug;
71
102
  private triggerClientHeartbeat;
72
103
  private shouldDeferHeartbeat;
73
104
  private handleClientMessage;
package/server-app.js CHANGED
@@ -76,9 +76,14 @@ exports.ResolveIOMainServer = void 0;
76
76
  var express = require("express");
77
77
  var xmlParser = require("express-xml-bodyparser");
78
78
  var http_1 = require("http");
79
+ var fs = require("fs");
79
80
  var jwt = require("jsonwebtoken");
80
81
  var moment = require("moment-timezone");
81
82
  var msgpackr_1 = require("msgpackr");
83
+ var os = require("os");
84
+ var path = require("path");
85
+ var perf_hooks_1 = require("perf_hooks");
86
+ var inspector = require("inspector");
82
87
  var url_1 = require("url");
83
88
  var WebSocket = require("ws");
84
89
  var log_collection_1 = require("./collections/log.collection");
@@ -109,6 +114,21 @@ var ResolveIOMainServer = /** @class */ (function () {
109
114
  this._clientRoutes = [];
110
115
  this._httpServerClosePromise = null;
111
116
  this._websocketServerClosePromise = null;
117
+ this._wsConnectDebug = false;
118
+ this._perfDebug = false;
119
+ this._perfDebugIntervalMs = 2000;
120
+ this._perfDebugTimer = null;
121
+ this._perfDebugLastCpu = null;
122
+ this._perfDebugLastTs = 0;
123
+ this._eventLoopHistogram = null;
124
+ this._cpuProfileOnStart = false;
125
+ this._cpuProfileAuto = false;
126
+ this._cpuProfileDurationMs = 15000;
127
+ this._cpuProfileThresholdPct = 90;
128
+ this._cpuProfileTriggerCount = 3;
129
+ this._cpuProfileHighCount = 0;
130
+ this._cpuProfileDir = null;
131
+ this._cpuProfileSession = null;
112
132
  this._lastErrorMsg = null;
113
133
  this._debugMsgRecv = 0;
114
134
  this._debugMsgQueue = 0;
@@ -143,11 +163,23 @@ var ResolveIOMainServer = /** @class */ (function () {
143
163
  case 0:
144
164
  this._serverStartTime = new Date();
145
165
  this._lastErrorMsg = null;
166
+ this._wsConnectDebug = this.resolveConnectDebug();
167
+ this._perfDebug = this.resolvePerfDebug();
168
+ this._cpuProfileOnStart = this.resolveCpuProfileOnStart();
169
+ this._cpuProfileAuto = this.resolveCpuProfileAuto();
170
+ this._cpuProfileDurationMs = this.resolveCpuProfileDurationMs();
171
+ this._cpuProfileThresholdPct = this.resolveCpuProfileThresholdPct();
172
+ this._cpuProfileTriggerCount = this.resolveCpuProfileTriggerCount();
173
+ this._cpuProfileDir = this.resolveCpuProfileDir();
146
174
  _a = this;
147
175
  return [4 /*yield*/, monitor_manager_1.MonitorManager.create()];
148
176
  case 1:
149
177
  _a._monitorManager = _b.sent();
150
178
  this._monitorManagerFunction = new monitor_manager_1.MonitorManagerFunction();
179
+ this.startPerfDebug();
180
+ if (this._cpuProfileOnStart) {
181
+ this.startCpuProfile('on-start');
182
+ }
151
183
  // Check for workers and decide what to start
152
184
  this._isWorkersEnabled = process.env.IS_WORKERS_ENABLED === 'true';
153
185
  this._isWorkerInstance = process.env.IS_WORKER_INSTANCE === 'true';
@@ -762,8 +794,9 @@ var ResolveIOMainServer = /** @class */ (function () {
762
794
  this._serverWSS.on('connection', function (ws, req) { return __awaiter(_this, void 0, void 0, function () {
763
795
  var workerId_1, workerIndex, workerInstance, rootUrl, requestUrl, workerIndexForLog, workerInstanceForLog, interval_1, lastComm_1, missedPongs_1, heartbeatIntervalMs, maxMissedPongs_1, maxSilenceMs_1;
764
796
  var _this = this;
765
- return __generator(this, function (_a) {
766
- switch (_a.label) {
797
+ var _a, _b;
798
+ return __generator(this, function (_c) {
799
+ switch (_c.label) {
767
800
  case 0:
768
801
  if (!(req.url && req.url.includes('workerToken='))) return [3 /*break*/, 1];
769
802
  workerId_1 = (0, common_1.objectIdHexString)();
@@ -778,7 +811,7 @@ var ResolveIOMainServer = /** @class */ (function () {
778
811
  workerIndex = requestUrl.searchParams.get('workerIndex');
779
812
  workerInstance = requestUrl.searchParams.get('workerInstance');
780
813
  }
781
- catch (_b) {
814
+ catch (_d) {
782
815
  workerIndex = null;
783
816
  workerInstance = null;
784
817
  }
@@ -885,9 +918,17 @@ var ResolveIOMainServer = /** @class */ (function () {
885
918
  ws['user_readonly'] = req['user_readonly'];
886
919
  ws['doc_user'] = req['doc_user'];
887
920
  this._websocketManager.addWebSocket(ws);
921
+ this.logConnectDebug('WS client connected', {
922
+ id_socket: ws['id_socket'],
923
+ id_user: ws['id_user'],
924
+ user: ws['user'],
925
+ url: req === null || req === void 0 ? void 0 : req.url,
926
+ ip: (_a = req === null || req === void 0 ? void 0 : req.socket) === null || _a === void 0 ? void 0 : _a.remoteAddress,
927
+ origin: (_b = req === null || req === void 0 ? void 0 : req.headers) === null || _b === void 0 ? void 0 : _b.origin
928
+ });
888
929
  return [4 /*yield*/, this._subscriptionManager.createLoggedInUser(ws['id_socket'])];
889
930
  case 2:
890
- _a.sent();
931
+ _c.sent();
891
932
  setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
892
933
  return __generator(this, function (_a) {
893
934
  switch (_a.label) {
@@ -994,14 +1035,20 @@ var ResolveIOMainServer = /** @class */ (function () {
994
1035
  .on('close', function () { return __awaiter(_this, void 0, void 0, function () {
995
1036
  return __generator(this, function (_a) {
996
1037
  switch (_a.label) {
997
- case 0: return [4 /*yield*/, this.unsubscribeWS(ws)];
1038
+ case 0:
1039
+ this.logConnectDebug('WS client closed', {
1040
+ id_socket: ws['id_socket'],
1041
+ id_user: ws['id_user'],
1042
+ user: ws['user']
1043
+ });
1044
+ return [4 /*yield*/, this.unsubscribeWS(ws)];
998
1045
  case 1:
999
1046
  _a.sent();
1000
1047
  return [2 /*return*/];
1001
1048
  }
1002
1049
  });
1003
1050
  }); });
1004
- _a.label = 3;
1051
+ _c.label = 3;
1005
1052
  case 3: return [2 /*return*/];
1006
1053
  }
1007
1054
  });
@@ -1087,6 +1134,11 @@ var ResolveIOMainServer = /** @class */ (function () {
1087
1134
  // If the top level is not an array, let's skip
1088
1135
  if (!Array.isArray(socketData[0])) {
1089
1136
  console.log('Invalid message format (expected array of arrays)', socketData);
1137
+ this.logConnectDebug('Invalid message format', {
1138
+ id_socket: ws ? ws['id_socket'] : null,
1139
+ user: ws ? ws['user'] : null,
1140
+ preview: Array.isArray(socketData) ? socketData.slice(0, 3) : socketData
1141
+ });
1090
1142
  return [2 /*return*/];
1091
1143
  }
1092
1144
  _b.label = 1;
@@ -1164,6 +1216,221 @@ var ResolveIOMainServer = /** @class */ (function () {
1164
1216
  var first = trimmed[0];
1165
1217
  return first === '[' || first === '{' || first === '"' || first === 'p' || first === 'P';
1166
1218
  };
1219
+ ResolveIOMainServer.prototype.resolveConnectDebug = function () {
1220
+ var _a, _b, _c;
1221
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1222
+ var raw = (_c = (_b = (_a = process.env.WS_CONNECT_DEBUG) !== null && _a !== void 0 ? _a : process.env.CONNECT_DEBUG) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config['WS_CONNECT_DEBUG']) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config['CONNECT_DEBUG'];
1223
+ return this.parseDebugFlag(raw);
1224
+ };
1225
+ ResolveIOMainServer.prototype.resolvePerfDebug = function () {
1226
+ var _a, _b, _c;
1227
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1228
+ var raw = (_c = (_b = (_a = process.env.PERF_DEBUG) !== null && _a !== void 0 ? _a : process.env.CPU_DEBUG) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config['PERF_DEBUG']) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config['CPU_DEBUG'];
1229
+ return this.parseDebugFlag(raw);
1230
+ };
1231
+ ResolveIOMainServer.prototype.resolveCpuProfileOnStart = function () {
1232
+ var _a, _b, _c;
1233
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1234
+ var raw = (_c = (_b = (_a = process.env.CPU_PROFILE_ON_START) !== null && _a !== void 0 ? _a : process.env.CPU_PROFILE_START) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_ON_START']) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_START'];
1235
+ return this.parseDebugFlag(raw);
1236
+ };
1237
+ ResolveIOMainServer.prototype.resolveCpuProfileAuto = function () {
1238
+ var _a;
1239
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1240
+ var raw = (_a = process.env.CPU_PROFILE_AUTO) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_AUTO'];
1241
+ return this.parseDebugFlag(raw);
1242
+ };
1243
+ ResolveIOMainServer.prototype.resolveCpuProfileDurationMs = function () {
1244
+ var _a, _b, _c;
1245
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1246
+ var raw = (_c = (_b = (_a = process.env.CPU_PROFILE_DURATION_MS) !== null && _a !== void 0 ? _a : process.env.PERF_PROFILE_DURATION_MS) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_DURATION_MS']) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config['PERF_PROFILE_DURATION_MS'];
1247
+ return this.parsePositiveInt(raw, this._cpuProfileDurationMs);
1248
+ };
1249
+ ResolveIOMainServer.prototype.resolveCpuProfileThresholdPct = function () {
1250
+ var _a, _b, _c;
1251
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1252
+ var raw = (_c = (_b = (_a = process.env.CPU_PROFILE_THRESHOLD_PCT) !== null && _a !== void 0 ? _a : process.env.PERF_PROFILE_THRESHOLD_PCT) !== null && _b !== void 0 ? _b : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_THRESHOLD_PCT']) !== null && _c !== void 0 ? _c : config === null || config === void 0 ? void 0 : config['PERF_PROFILE_THRESHOLD_PCT'];
1253
+ return this.parsePositiveFloat(raw, this._cpuProfileThresholdPct);
1254
+ };
1255
+ ResolveIOMainServer.prototype.resolveCpuProfileTriggerCount = function () {
1256
+ var _a;
1257
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1258
+ var raw = (_a = process.env.CPU_PROFILE_TRIGGER_COUNT) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_TRIGGER_COUNT'];
1259
+ return this.parsePositiveInt(raw, this._cpuProfileTriggerCount);
1260
+ };
1261
+ ResolveIOMainServer.prototype.resolveCpuProfileDir = function () {
1262
+ var _a;
1263
+ var config = resolveio_server_app_1.ResolveIOServer.getServerConfig ? resolveio_server_app_1.ResolveIOServer.getServerConfig() : null;
1264
+ var raw = (_a = process.env.CPU_PROFILE_DIR) !== null && _a !== void 0 ? _a : config === null || config === void 0 ? void 0 : config['CPU_PROFILE_DIR'];
1265
+ return typeof raw === 'string' && raw.trim() ? raw.trim() : null;
1266
+ };
1267
+ ResolveIOMainServer.prototype.parsePositiveInt = function (value, fallback) {
1268
+ var parsed = parseInt(value !== null && value !== void 0 ? value : '', 10);
1269
+ if (Number.isNaN(parsed) || parsed <= 0) {
1270
+ return fallback;
1271
+ }
1272
+ return parsed;
1273
+ };
1274
+ ResolveIOMainServer.prototype.parsePositiveFloat = function (value, fallback) {
1275
+ var parsed = parseFloat(value !== null && value !== void 0 ? value : '');
1276
+ if (Number.isNaN(parsed) || parsed <= 0) {
1277
+ return fallback;
1278
+ }
1279
+ return parsed;
1280
+ };
1281
+ ResolveIOMainServer.prototype.startPerfDebug = function () {
1282
+ var _this = this;
1283
+ var _a;
1284
+ if (!this._perfDebug || this._perfDebugTimer) {
1285
+ return;
1286
+ }
1287
+ this._perfDebugIntervalMs = this.parsePositiveInt((_a = process.env.PERF_DEBUG_INTERVAL_MS) !== null && _a !== void 0 ? _a : process.env.CPU_DEBUG_INTERVAL_MS, this._perfDebugIntervalMs);
1288
+ this._perfDebugLastCpu = process.cpuUsage();
1289
+ this._perfDebugLastTs = Date.now();
1290
+ this._eventLoopHistogram = (0, perf_hooks_1.monitorEventLoopDelay)({ resolution: 20 });
1291
+ this._eventLoopHistogram.enable();
1292
+ this._perfDebugTimer = setInterval(function () {
1293
+ var now = Date.now();
1294
+ var elapsedMs = now - _this._perfDebugLastTs;
1295
+ var cpuDiff = _this._perfDebugLastCpu ? process.cpuUsage(_this._perfDebugLastCpu) : process.cpuUsage();
1296
+ var cpuMs = (cpuDiff.user + cpuDiff.system) / 1000;
1297
+ var cpuPct = elapsedMs > 0 ? (cpuMs / elapsedMs) * 100 : 0;
1298
+ var mem = process.memoryUsage();
1299
+ var heapUsedMb = (0, common_1.round)((mem.heapUsed / 1024 / 1024) * 10) / 10;
1300
+ var rssMb = (0, common_1.round)((mem.rss / 1024 / 1024) * 10) / 10;
1301
+ var handles = typeof process._getActiveHandles === 'function'
1302
+ ? process._getActiveHandles().length
1303
+ : null;
1304
+ var requests = typeof process._getActiveRequests === 'function'
1305
+ ? process._getActiveRequests().length
1306
+ : null;
1307
+ var histogram = _this._eventLoopHistogram;
1308
+ var eventLoop = histogram ? {
1309
+ meanMs: (0, common_1.round)((histogram.mean / 1e6) * 100) / 100,
1310
+ p50Ms: (0, common_1.round)((histogram.percentile(50) / 1e6) * 100) / 100,
1311
+ p95Ms: (0, common_1.round)((histogram.percentile(95) / 1e6) * 100) / 100,
1312
+ p99Ms: (0, common_1.round)((histogram.percentile(99) / 1e6) * 100) / 100,
1313
+ maxMs: (0, common_1.round)((histogram.max / 1e6) * 100) / 100
1314
+ } : null;
1315
+ histogram === null || histogram === void 0 ? void 0 : histogram.reset();
1316
+ console.log(new Date(), '[Perf Debug]', JSON.stringify({
1317
+ cpuPct: (0, common_1.round)(cpuPct * 10) / 10,
1318
+ cpuMs: (0, common_1.round)(cpuMs),
1319
+ elapsedMs: elapsedMs,
1320
+ eventLoop: eventLoop,
1321
+ heapUsedMb: heapUsedMb,
1322
+ rssMb: rssMb,
1323
+ activeHandles: handles,
1324
+ activeRequests: requests,
1325
+ msgRecv: _this._debugMsgRecv,
1326
+ msgQueue: _this._debugMsgQueue
1327
+ }));
1328
+ if (_this._cpuProfileAuto) {
1329
+ if (cpuPct >= _this._cpuProfileThresholdPct) {
1330
+ _this._cpuProfileHighCount += 1;
1331
+ }
1332
+ else {
1333
+ _this._cpuProfileHighCount = 0;
1334
+ }
1335
+ if (_this._cpuProfileHighCount >= _this._cpuProfileTriggerCount) {
1336
+ _this._cpuProfileHighCount = 0;
1337
+ _this.startCpuProfile('auto-high-cpu');
1338
+ }
1339
+ }
1340
+ _this._perfDebugLastCpu = process.cpuUsage();
1341
+ _this._perfDebugLastTs = now;
1342
+ }, this._perfDebugIntervalMs);
1343
+ };
1344
+ ResolveIOMainServer.prototype.startCpuProfile = function (trigger) {
1345
+ var _this = this;
1346
+ if (this._cpuProfileSession) {
1347
+ return;
1348
+ }
1349
+ try {
1350
+ var session_1 = new inspector.Session();
1351
+ session_1.connect();
1352
+ session_1.post('Profiler.enable', function () {
1353
+ session_1.post('Profiler.start', function () {
1354
+ _this._cpuProfileSession = session_1;
1355
+ console.log(new Date(), '[Perf Debug]', 'CPU profile started', trigger);
1356
+ setTimeout(function () {
1357
+ _this.stopCpuProfile(trigger);
1358
+ }, _this._cpuProfileDurationMs);
1359
+ });
1360
+ });
1361
+ }
1362
+ catch (error) {
1363
+ console.error(new Date(), '[Perf Debug]', 'CPU profile start failed', error);
1364
+ }
1365
+ };
1366
+ ResolveIOMainServer.prototype.stopCpuProfile = function (trigger) {
1367
+ var _this = this;
1368
+ var session = this._cpuProfileSession;
1369
+ if (!session) {
1370
+ return;
1371
+ }
1372
+ session.post('Profiler.stop', function (err, res) {
1373
+ var _a;
1374
+ if (err) {
1375
+ console.error(new Date(), '[Perf Debug]', 'CPU profile stop failed', err);
1376
+ }
1377
+ else {
1378
+ try {
1379
+ var dir = _this.resolveWritableProfileDir();
1380
+ var filename = "resolveio-cpuprofile-".concat(process.pid, "-").concat(Date.now(), ".cpuprofile");
1381
+ var filePath = path.join(dir, filename);
1382
+ fs.writeFileSync(filePath, JSON.stringify((_a = res === null || res === void 0 ? void 0 : res.profile) !== null && _a !== void 0 ? _a : {}));
1383
+ console.log(new Date(), '[Perf Debug]', 'CPU profile saved', filePath, trigger);
1384
+ }
1385
+ catch (writeErr) {
1386
+ console.error(new Date(), '[Perf Debug]', 'CPU profile write failed', writeErr);
1387
+ }
1388
+ }
1389
+ try {
1390
+ session.disconnect();
1391
+ }
1392
+ catch (_b) { }
1393
+ _this._cpuProfileSession = null;
1394
+ });
1395
+ };
1396
+ ResolveIOMainServer.prototype.resolveWritableProfileDir = function () {
1397
+ var preferred = this._cpuProfileDir;
1398
+ if (preferred) {
1399
+ try {
1400
+ fs.mkdirSync(preferred, { recursive: true });
1401
+ return preferred;
1402
+ }
1403
+ catch (_a) { }
1404
+ }
1405
+ return os.tmpdir();
1406
+ };
1407
+ ResolveIOMainServer.prototype.parseDebugFlag = function (value) {
1408
+ if (value === true) {
1409
+ return true;
1410
+ }
1411
+ if (value === false || value === null || value === undefined) {
1412
+ return false;
1413
+ }
1414
+ if (typeof value === 'number') {
1415
+ return value === 1;
1416
+ }
1417
+ if (typeof value === 'string') {
1418
+ var normalized = value.trim().toLowerCase();
1419
+ return ['1', 'true', 'yes', 'y', 'on'].includes(normalized);
1420
+ }
1421
+ return false;
1422
+ };
1423
+ ResolveIOMainServer.prototype.logConnectDebug = function (message, details) {
1424
+ if (!this._wsConnectDebug) {
1425
+ return;
1426
+ }
1427
+ if (details) {
1428
+ console.log(new Date(), '[Connect Debug]', message, JSON.stringify(details));
1429
+ }
1430
+ else {
1431
+ console.log(new Date(), '[Connect Debug]', message);
1432
+ }
1433
+ };
1167
1434
  ResolveIOMainServer.prototype.triggerClientHeartbeat = function (ws) {
1168
1435
  return __awaiter(this, void 0, void 0, function () {
1169
1436
  var err_1;
@@ -1240,6 +1507,15 @@ var ResolveIOMainServer = /** @class */ (function () {
1240
1507
  if (!(type === 'subscription')) return [3 /*break*/, 4];
1241
1508
  subType = msg[4];
1242
1509
  pub = msg[5];
1510
+ this.logConnectDebug('Subscription message', {
1511
+ subType: subType,
1512
+ publication: pub,
1513
+ messageId: messageId,
1514
+ messageRoute: messageRoute_1,
1515
+ args: Math.max(0, msg.length - 6),
1516
+ id_socket: ws ? ws['id_socket'] : null,
1517
+ user: ws ? ws['user'] : null
1518
+ });
1243
1519
  if (!(subType === 'sub')) return [3 /*break*/, 2];
1244
1520
  return [4 /*yield*/, this._subscriptionManager.subscribe(messageRoute_1, messageDate, ws, messageId, pub, msg.slice(6))];
1245
1521
  case 1:
@@ -1533,6 +1809,11 @@ var ResolveIOMainServer = /** @class */ (function () {
1533
1809
  if (this._subscriptionManager && this._methodManager.getEnableDebug()) {
1534
1810
  console.log(new Date(), 'Server App', 'Unsub WS', ws['user'], ws['id_socket']);
1535
1811
  }
1812
+ this.logConnectDebug('WS unsubscribe', {
1813
+ id_socket: ws ? ws['id_socket'] : null,
1814
+ id_user: ws ? ws['id_user'] : null,
1815
+ user: ws ? ws['user'] : null
1816
+ });
1536
1817
  return [4 /*yield*/, this._subscriptionManager.unsubscribeAll(ws)];
1537
1818
  case 1:
1538
1819
  _a.sent();