Skip to content

Commit

Permalink
Merge pull request #2564 from kuzzleio/feat/KZLPRD-616-socket-payload…
Browse files Browse the repository at this point in the history
…-closing-logging

feat(protocols): add logging socket closing
  • Loading branch information
rolljee authored Dec 19, 2024
2 parents 5e185f1 + 52f7d18 commit 3d6c8b2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/core/network/protocols/httpwsProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,22 @@ class HttpWsProtocol extends Protocol {
return;
}

const reason = Buffer.from(message || "").toString();

// This hack is only here to indicate that uWebSockets killed the connection early
// because the received payload exceeded the configured threshold.
if (code === 1006 && reason.startsWith("Received too big message")) {
global.kuzzle.log.error(
`[${connection.id}] connection closed: payload exceeded the threshold`,
);
}

if (debugWS.enabled) {
debugWS(
"[%s] received a `close` event (CODE: %d, REASON: %s)",
connection.id,
code,
Buffer.from(message || "").toString(),
reason,
);
}
this.entryPoint.removeConnection(connection.id);
Expand Down

0 comments on commit 3d6c8b2

Please sign in to comment.