diff options
author | halna_Tanaguru <fhalna@oceaneconsulting.com> | 2017-04-04 12:06:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 12:06:53 +0200 |
commit | 3abb0f7bc708ae8ca387aee8560b9558f8b209ba (patch) | |
tree | 6014fdec3201d9e40fa244b821bdaffc83bfa131 /streaming/index.js | |
parent | 3f30ae1f97717177f29711d5b99d7970c6b75b3e (diff) | |
parent | eb023beb4975a019d6a3b3091483c91c2c837bbd (diff) |
Merge branch 'master' into development
Diffstat (limited to 'streaming/index.js')
-rw-r--r-- | streaming/index.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/streaming/index.js b/streaming/index.js index 0f838e411..7edf6203f 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -215,8 +215,11 @@ const streamHttpEnd = req => (id, listener) => { // Setup stream output to WebSockets const streamToWs = (req, ws) => { + const heartbeat = setInterval(() => ws.ping(), 15000) + ws.on('close', () => { log.verbose(req.requestId, `Ending stream for ${req.accountId}`) + clearInterval(heartbeat) }) return (event, payload) => { @@ -234,6 +237,10 @@ const streamWsEnd = ws => (id, listener) => { ws.on('close', () => { unsubscribe(id, listener) }) + + ws.on('error', e => { + unsubscribe(id, listener) + }) } app.use(setRequestId) |