From fda2ed7d7beae7e5861907de279129c9db0180be Mon Sep 17 00:00:00 2001 From: Christian Sturm Date: Fri, 28 Dec 2018 19:40:04 +0100 Subject: [PATCH] Use location.name instead of _server_name This makes sure that even when there is a forward through a router, VirtualBox, an SSH tunnel, the websocket connections will go to the right place instead of simply failing. --- public/js/clonos.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/js/clonos.js b/public/js/clonos.js index 7881f757..2a58077f 100644 --- a/public/js/clonos.js +++ b/public/js/clonos.js @@ -2606,7 +2606,7 @@ var clonos={ wsconnect:function() { this.client_id=Math.random(10000); // поменять на сессию - this.socket = new WebSocket("ws://"+_server_name+":8023/clonos"+location.pathname); + this.socket = new WebSocket("ws://"+location.hostname+":8023/clonos"+location.pathname); $(this.socket).on('open',$.proxy(this.wsopen,this)) .on('close',$.proxy(this.wsclose,this)) .on('error',$.proxy(this.wserror,this)) @@ -3251,7 +3251,7 @@ graphs={ { console.log('Соединяемся по сокету'); this.client_id=this.name; - socket = new WebSocket("ws://"+_server_name+":8024/graph"+location.pathname+"client-"+Math.random()); + socket = new WebSocket("ws://"+location.hostname+":8024/graph"+location.pathname+"client-"+Math.random()); $(socket).on('open',$.proxy(this.wsopen,this)) .on('close',$.proxy(this.wsclose,this)) .on('error',$.proxy(this.wserror,this)) @@ -3598,4 +3598,4 @@ function ws_debug(){ $(window).on('load',function(){clonos.start();}); $(window).on('unload',function(){}); /* эта функция заставляет FireFox запускать JS-функции при нажатии кнопки «Назад» http://stackoverflow.com/questions/2638292/after-travelling-back-in-firefox-history-javascript-wont-run */ -$(function(){clonos.loadData('getJsonPage',$.proxy(clonos.onLoadData,clonos));}); \ No newline at end of file +$(function(){clonos.loadData('getJsonPage',$.proxy(clonos.onLoadData,clonos));});