possible memory leak fixes
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
"dlob-publish": "ts-node src/publishers/dlobPublisher.ts",
|
||||
"trades-publish": "ts-node src/publishers/tradesPublisher.ts",
|
||||
"ws-manager": "ts-node src/wsConnectionManager.ts",
|
||||
"ws-manager:inspect": "yarn build && node --inspect ./lib/wsConnectionManager.js",
|
||||
"dev:inspect": "yarn build && node --inspect ./lib/index.js",
|
||||
"dev:debug": "yarn build && node --inspect-brk --inspect=2230 ./lib/index.js",
|
||||
"example": "ts-node example/client.ts",
|
||||
|
||||
@@ -34,6 +34,7 @@ export const getRedisClient = (
|
||||
return false;
|
||||
},
|
||||
maxRetriesPerRequest: null, // unlimited retries
|
||||
enableOfflineQueue: false,
|
||||
});
|
||||
|
||||
redisClient.on('connect', () => {
|
||||
|
||||
@@ -99,7 +99,10 @@ async function main() {
|
||||
const subscribers = channelSubscribers.get(subscribedChannel);
|
||||
if (subscribers) {
|
||||
subscribers.forEach((ws) => {
|
||||
ws.send(JSON.stringify({ channel: subscribedChannel, data: message }));
|
||||
if (ws.readyState === WebSocket.OPEN)
|
||||
ws.send(
|
||||
JSON.stringify({ channel: subscribedChannel, data: message })
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -110,7 +113,6 @@ async function main() {
|
||||
|
||||
wss.on('connection', (ws: WebSocket) => {
|
||||
console.log('Client connected');
|
||||
console.log('Number of active connections:', wss.clients.size);
|
||||
wsConnectionsGauge.inc();
|
||||
|
||||
ws.on('message', async (msg) => {
|
||||
@@ -245,7 +247,6 @@ async function main() {
|
||||
subscribedChannels.delete(channel);
|
||||
}
|
||||
});
|
||||
console.log('Number of active connections:', wss.clients.size);
|
||||
wsConnectionsGauge.dec();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user