diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js
index a566fc7..017dc90 100755
--- a/htdocs/openwebrx.js
+++ b/htdocs/openwebrx.js
@@ -1251,7 +1251,7 @@ function on_ws_closed()
audio_node.disconnect();
}
catch (dont_care) {}
- divlog("WebSocket has closed unexpectedly. Please reload the page.", 1);
+ divlog("WebSocket has closed unexpectedly. Please reload the page.", 1);
}
function on_ws_error(event)
@@ -1259,9 +1259,15 @@ function on_ws_error(event)
divlog("WebSocket error.",1);
}
+String.prototype.startswith=function(str){ return this.indexOf(str) == 0; }; //http://stackoverflow.com/questions/646628/how-to-check-if-a-string-startswith-another-string
+
function open_websocket()
{
- //ws_url="ws://"+(window.location.origin.split("://")[1])+"/ws/" //guess automatically
+ if(ws_url.startswith("ws://localhost:")&&window.location.hostname!="127.0.0.1"&&window.location.hostname!="localhost")
+ {
+ divlog("Server administrator should set server_hostname correctly, because it is left as \"localhost\". Now guessing hostname from page URL.",1);
+ ws_url="ws://"+(window.location.origin.split("://")[1])+"/ws/"; //guess automatically
+ }
if (!("WebSocket" in window))
divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser.");
ws = new WebSocket(ws_url+client_id);
diff --git a/openwebrx.py b/openwebrx.py
index 41a97ed..9847f50 100755
--- a/openwebrx.py
+++ b/openwebrx.py
@@ -153,10 +153,13 @@ def spectrum_thread_function():
data=dsp.read(cfg.fft_size*4)
#print "gotcha",len(data),"bytes of spectrum data via spectrum_thread_function()"
clients_mutex.acquire()
+ correction=0
for i in range(0,len(clients)):
+ i-=correction
if (clients[i].ws_started):
if clients[i].spectrum_queue.full():
close_client(i, False)
+ correction+=1
else:
clients[i].spectrum_queue.put([data]) # add new string by "reference" to all clients
clients_mutex.release()