From 812dca2df44f2540be19ab61290723153d677f13 Mon Sep 17 00:00:00 2001 From: Drew Fisher Date: Sun, 18 May 2014 21:25:44 -0400 Subject: [PATCH] Make websocket bind to the host in the specified URI It's especially confusing to try to debug this if there's still a websocket server running at the place you're wrongly connecting to... --- reactornado/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/reactornado/main.js b/reactornado/main.js index 3c2147a..8353f2d 100644 --- a/reactornado/main.js +++ b/reactornado/main.js @@ -5,7 +5,9 @@ window.conversations = {} // buid -> {proto, account, buddy, messages[], visible window.onload = function () { // Create websocket and attach to window - var ws = new WebSocket("ws://localhost:8889/ws"); + var scheme = (window.location.protocol === "https:") ? "wss:" : "ws:" ; + var ws_uri = scheme + "//" + window.location.host + "/ws"; + var ws = new WebSocket(ws_uri); ws.onmessage = function(evt) { //console.log("message received: " + evt.data); -- 2.39.2