From 1ceb9b5f4b8021265e66b7d0c5b3d76a013e2a04 Mon Sep 17 00:00:00 2001 From: Kyle Kingsbury Date: Tue, 18 Feb 2014 13:22:23 -0800 Subject: [PATCH] subs.js: fix a reconnection bug Subscriptions would mistakenly report being closed due to a reversed pair of connection state constants in the ws/sse switch, in isOpen(). This caused sockets to consider themselves open when they were, in fact, closed. --- lib/riemann/dash/public/subs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/riemann/dash/public/subs.js b/lib/riemann/dash/public/subs.js index 5ce5685..2ec8df3 100644 --- a/lib/riemann/dash/public/subs.js +++ b/lib/riemann/dash/public/subs.js @@ -78,9 +78,9 @@ var subs = (function() { isOpen: function() { if (server_type == "ws") { - return this.ws && (this.ws.readyState != EventSource.CLOSED) - } else { return this.ws && (this.ws.readyState != WebSocket.CLOSED) + } else { + return this.ws && (this.ws.readyState != EventSource.CLOSED) } }, isClosed: function() { return !this.isOpen() }, @@ -99,6 +99,7 @@ var subs = (function() { open: function() { if (this.isOpen()) return this; + console.log("will open url: " + this.url()); var ws;