additional ws connection logging
This commit is contained in:
@@ -110,6 +110,7 @@ async function main() {
|
|||||||
|
|
||||||
wss.on('connection', (ws: WebSocket) => {
|
wss.on('connection', (ws: WebSocket) => {
|
||||||
console.log('Client connected');
|
console.log('Client connected');
|
||||||
|
console.log('Number of active connections:', wss.clients.size);
|
||||||
wsConnectionsGauge.inc();
|
wsConnectionsGauge.inc();
|
||||||
|
|
||||||
ws.on('message', async (msg) => {
|
ws.on('message', async (msg) => {
|
||||||
@@ -235,6 +236,7 @@ async function main() {
|
|||||||
|
|
||||||
// Handle disconnection
|
// Handle disconnection
|
||||||
ws.on('close', () => {
|
ws.on('close', () => {
|
||||||
|
console.log('Client disconnected');
|
||||||
// Clear any existing intervals and timeouts
|
// Clear any existing intervals and timeouts
|
||||||
channelSubscribers.forEach((subscribers, channel) => {
|
channelSubscribers.forEach((subscribers, channel) => {
|
||||||
if (subscribers.delete(ws) && subscribers.size === 0) {
|
if (subscribers.delete(ws) && subscribers.size === 0) {
|
||||||
@@ -243,6 +245,7 @@ async function main() {
|
|||||||
subscribedChannels.delete(channel);
|
subscribedChannels.delete(channel);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log('Number of active connections:', wss.clients.size);
|
||||||
wsConnectionsGauge.dec();
|
wsConnectionsGauge.dec();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user