possible memory leak fixes
This commit is contained in:
@@ -56,6 +56,7 @@
|
|||||||
"dlob-publish": "ts-node src/publishers/dlobPublisher.ts",
|
"dlob-publish": "ts-node src/publishers/dlobPublisher.ts",
|
||||||
"trades-publish": "ts-node src/publishers/tradesPublisher.ts",
|
"trades-publish": "ts-node src/publishers/tradesPublisher.ts",
|
||||||
"ws-manager": "ts-node src/wsConnectionManager.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:inspect": "yarn build && node --inspect ./lib/index.js",
|
||||||
"dev:debug": "yarn build && node --inspect-brk --inspect=2230 ./lib/index.js",
|
"dev:debug": "yarn build && node --inspect-brk --inspect=2230 ./lib/index.js",
|
||||||
"example": "ts-node example/client.ts",
|
"example": "ts-node example/client.ts",
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const getRedisClient = (
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
maxRetriesPerRequest: null, // unlimited retries
|
maxRetriesPerRequest: null, // unlimited retries
|
||||||
|
enableOfflineQueue: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
redisClient.on('connect', () => {
|
redisClient.on('connect', () => {
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ async function main() {
|
|||||||
const subscribers = channelSubscribers.get(subscribedChannel);
|
const subscribers = channelSubscribers.get(subscribedChannel);
|
||||||
if (subscribers) {
|
if (subscribers) {
|
||||||
subscribers.forEach((ws) => {
|
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) => {
|
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) => {
|
||||||
@@ -245,7 +247,6 @@ 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