send heartbeat and detect redis cache better

This commit is contained in:
Nour Alharithi
2023-12-12 09:56:14 -08:00
parent 436e63dbd5
commit 59b88f753d
2 changed files with 9 additions and 2 deletions

View File

@@ -941,7 +941,7 @@ const main = async () => {
let l2Formatted: any; let l2Formatted: any;
if (useRedis) { if (useRedis) {
if ( if (
marketType === 'perp' && !isSpot &&
normedParam['includeVamm'].toLowerCase() === 'true' && normedParam['includeVamm'].toLowerCase() === 'true' &&
normedParam['includeOracle'].toLowerCase() === 'true' && normedParam['includeOracle'].toLowerCase() === 'true' &&
!normedParam['grouping'] !normedParam['grouping']
@@ -966,7 +966,7 @@ const main = async () => {
l2Formatted = parsedRedisL2; l2Formatted = parsedRedisL2;
} }
} else if ( } else if (
marketType === 'spot' && isSpot &&
normedParam['includePhoenix'].toLowerCase() === 'true' && normedParam['includePhoenix'].toLowerCase() === 'true' &&
normedParam['includeSerum'].toLowerCase() === 'true' && normedParam['includeSerum'].toLowerCase() === 'true' &&
!normedParam['grouping'] !normedParam['grouping']

View File

@@ -257,6 +257,13 @@ async function main() {
ws.on('error', (error) => { ws.on('error', (error) => {
console.error('Socket error:', error); console.error('Socket error:', error);
}); });
// Set interval to send heartbeat every 5 seconds
setInterval(() => {
ws.send(JSON.stringify({
channel: 'heartbeat'
}));
}, 5000);
}); });
server.listen(WS_PORT, () => { server.listen(WS_PORT, () => {