socket-function 0.101.0 → 0.103.0

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": "socket-function",
3
- "version": "0.101.0",
3
+ "version": "0.103.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -486,7 +486,7 @@ export async function createCallFactory(
486
486
  }
487
487
  if (SocketFunction.logMessages) {
488
488
  let call = callbackObj.call;
489
- console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tRETURN\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
489
+ console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tRETURN\t${call.classGuid}.${call.functionName} at ${Date.now()}, (${nodeId} / ${localNodeId})`);
490
490
  }
491
491
  if (call.isResultCompressed) {
492
492
  call.result = await decompressObj(call.result as Buffer);
@@ -565,11 +565,15 @@ export async function createCallFactory(
565
565
  - The upgrade request finishes, at least once: Received websocket upgrade
566
566
  - AND, we are receiving some calls, so... that appears to work.
567
567
  - Maybe the time calls never finish?
568
+ - We added logging for when calls finish as well, so we can tell if all the TimeController calls timed out
569
+ - ALSO, added more logging to see if the calls were from the same client (which WOULD be a bug, because
570
+ the client shouldn't be calling us so often), or, different clients.
571
+ - We DO receive more connections than http connections closed. But not that many more...
568
572
  */
569
573
  console.log(red(`Call to ${call.classGuid}.${call.functionName} at ${Date.now()}`));
570
574
  }
571
575
  if (SocketFunction.logMessages) {
572
- console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tEVALUATE\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
576
+ console.log(`SIZE\t${(formatNumberSuffixed(resultSize) + "B").padEnd(4, " ")}\tEVALUATE\t${call.classGuid}.${call.functionName} at ${Date.now()}, (${nodeId} / ${localNodeId})`);
573
577
  }
574
578
  if (time > SocketFunction.WIRE_WARN_TIME) {
575
579
  console.log(red(`Slow parse, took ${time}ms to parse ${resultSize} bytes, for call to ${call.classGuid}.${call.functionName}`));
@@ -586,7 +590,7 @@ export async function createCallFactory(
586
590
  };
587
591
  if (SocketFunction.logMessages) {
588
592
  time = Date.now() - time;
589
- console.log(`DUR\t${(formatTime(time)).padEnd(6, " ")}\tFINISH\t${call.classGuid}.${call.functionName} at ${Date.now()}`);
593
+ console.log(`DUR\t${(formatTime(time)).padEnd(6, " ")}\tFINISH\t${call.classGuid}.${call.functionName} at ${Date.now()}, (${nodeId} / ${localNodeId})`);
590
594
  }
591
595
  if (shouldCompressCall(call)) {
592
596
  response.result = await compressObj(response.result) as any;
@@ -80,7 +80,8 @@ export async function startSocketServer(
80
80
  };
81
81
  if (!httpsServerLast) {
82
82
  httpsServerLast = https.createServer(lastOptions);
83
- // We REALLY don't want keep alive, at all, as keep alives break so many things.
83
+ // NOTE: This MIGHT be different than the keep alive option? Probably not, but also...
84
+ // something weird is happening with connections...
84
85
  httpsServerLast.keepAliveTimeout = 0;
85
86
  } else {
86
87
  httpsServerLast.setSecureContext(lastOptions);
@@ -167,6 +168,8 @@ export async function startSocketServer(
167
168
  // our websockets, so... we really don't need to keep alive our HTTP requests
168
169
  // (and our images go through cloudflare, so we don't even need keep alive for that)
169
170
  keepAlive: false,
171
+ keepAliveInitialDelay: 0,
172
+ noDelay: true,
170
173
  };
171
174
  if (!config.cert) {
172
175
  throw new Error("No cert specified");
@@ -181,7 +184,7 @@ export async function startSocketServer(
181
184
  sniServers.set(domain, await setupHTTPSServer(obj));
182
185
  }
183
186
 
184
- let httpServer = http.createServer({}, async function (req, res) {
187
+ let httpServer = http.createServer({ keepAlive: false, }, async function (req, res) {
185
188
  let url = new URL("http://" + req.headers.host + req.url);
186
189
  url.protocol = "https:";
187
190
  //url.hostname = opts.hostname;
@@ -189,6 +192,7 @@ export async function startSocketServer(
189
192
  res.writeHead(301, { Location: url + "" });
190
193
  res.end();
191
194
  });
195
+ httpServer.keepAliveTimeout = 0;
192
196
  httpServer.on("error", e => {
193
197
  console.error(`HTTP error ${e.stack}`);
194
198
  });
@@ -257,6 +261,11 @@ export async function startSocketServer(
257
261
  socket.on("error", (e) => {
258
262
  console.error(`TCP socket error for ${debug}, ${e.stack}`);
259
263
  });
264
+ socket.on("close", () => {
265
+ if (!SocketFunction.silent) {
266
+ console.log(`TCP socket closed for ${debug}`);
267
+ }
268
+ });
260
269
  });
261
270
 
262
271