[price-service] Handle WS error (#501)

This commit is contained in:
Ali Behjati 2023-01-17 15:42:59 +01:00 committed by GitHub
parent 47c9993675
commit 9cbdeb3588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -233,6 +233,10 @@ export class WebSocketAPI {
this.aliveClients.add(ws); this.aliveClients.add(ws);
}); });
ws.on("error", (err: Error) => {
logger.warn(`Err with client ${this.wsId.get(ws)}: ${err}`);
});
ws.on("close", (_code: number, _reason: Buffer) => { ws.on("close", (_code: number, _reason: Buffer) => {
logger.info(`client ${this.wsId.get(ws)} closed the connection.`); logger.info(`client ${this.wsId.get(ws)} closed the connection.`);
this.promClient?.addWebSocketInteraction("close", "ok"); this.promClient?.addWebSocketInteraction("close", "ok");