From 022cceaf602c3471f5a6193f7baacfb4c94576dc Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 6 Sep 2016 15:56:36 +0200 Subject: [PATCH] Improved web socket port detection (added support for window.location.port). --- app/assets/javascripts/app/lib/app_post/websocket.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/websocket.coffee b/app/assets/javascripts/app/lib/app_post/websocket.coffee index 6664a52f1..b421e2388 100644 --- a/app/assets/javascripts/app/lib/app_post/websocket.coffee +++ b/app/assets/javascripts/app/lib/app_post/websocket.coffee @@ -199,10 +199,13 @@ class _webSocketSingleton extends App.Controller protocol = 'wss://' if @backend is 'websocket' - @ws = new window.WebSocket( protocol + window.location.hostname + '/ws' ) + port = '' + if window.location.port && window.location.port != '' + port = ":#{window.location.port}" + @ws = new window.WebSocket("#{protocol}#{window.location.hostname}#{port}/ws") else if @backend is 'websocketPort' @backend_port = App.Config.get('websocket_port') || '6042' - @ws = new window.WebSocket( protocol + window.location.hostname + ':' + @backend_port + '/' ) + @ws = new window.WebSocket("#{protocol}#{window.location.hostname}:#{@backend_port}/") else @_ajaxInit()