From cb380d5cbc9d4194d1ecfdbc4cc5c718e4794679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 6 Apr 2017 14:39:18 +0200 Subject: [PATCH] More robust websocket writting --- client.coffee | 5 ++++- subscription.coffee | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client.coffee b/client.coffee index 34dbd81..ac6c712 100644 --- a/client.coffee +++ b/client.coffee @@ -44,7 +44,10 @@ class Client @.subscriptionManager.remove(routing_key) sendPong: -> - @ws.send(JSON.stringify({cmd: "pong"})) + try + @ws.send(JSON.stringify({cmd: "pong"})) + catch e + console.error("Error: ", e) close: () -> if @.subscriptionManager diff --git a/subscription.coffee b/subscription.coffee index 6f2b955..b5b887e 100644 --- a/subscription.coffee +++ b/subscription.coffee @@ -14,7 +14,10 @@ class Subscription clientMsg.routing_key = msg.fields.routingKey clientMsgStr = JSON.stringify(clientMsg) - @ws.send clientMsgStr + try + @ws.send clientMsgStr + catch e + console.error("Error: ", e) start: () -> queue.subscribe(@client_id, @routing_key, @.handleMessage.bind(@))