Hey folks,
We’re trying to keep a persistent connection to /v2/analytics/events using ws in Node.js. The goal is to capture real-time adherence data without dropping the stream.
Here’s the basic setup:
ws.on('close', () => {
console.log('Connection closed, reconnecting...');
setTimeout(() => connect(), 5000);
});
The issue is that after a few minutes, the connection drops with code 1006. I’m just adding a simple timeout right now. Is there a better way to handle this? The docs don’t say much about backoff strategies.
We’re seeing high error rates in our logs. Any ideas on how to stabilize this?