mirror of
https://github.com/mempool/mempool.git
synced 2024-11-19 09:52:14 +01:00
More verbose websocket error logs
This commit is contained in:
parent
0f04f751e1
commit
652100f774
@ -94,10 +94,11 @@ class WebsocketHandler {
|
||||
throw new Error('WebSocket.Server is not set');
|
||||
}
|
||||
|
||||
this.wss.on('connection', (client: WebSocket) => {
|
||||
this.wss.on('connection', (client: WebSocket, req) => {
|
||||
this.numConnected++;
|
||||
client['remoteAddress'] = req.headers['x-forwarded-for'] || req.socket?.remoteAddress || 'unknown';
|
||||
client.on('error', (e) => {
|
||||
logger.info('websocket client error: ' + (e instanceof Error ? e.message : e));
|
||||
logger.info(`websocket client error from ${client['remoteAddress']}: ` + (e instanceof Error ? e.message : e));
|
||||
client.close();
|
||||
});
|
||||
client.on('close', () => {
|
||||
@ -285,7 +286,7 @@ class WebsocketHandler {
|
||||
client.send(serializedResponse);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.debug('Error parsing websocket message: ' + (e instanceof Error ? e.message : e));
|
||||
logger.debug(`Error parsing websocket message from ${client['remoteAddress']}: ` + (e instanceof Error ? e.message : e));
|
||||
client.close();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user