diff --git a/sample.html b/sample.html
index e088deea6..48eb4a970 100755
--- a/sample.html
+++ b/sample.html
@@ -1401,17 +1401,19 @@
Options
}
function startConnection(config) {
- host = $('#connectionHost').val().trim();
- usingSecure = $("#connectionUsingSecure").prop('checked');
+ var host = $('#connectionHost').val().trim();
+ var usingSecure = $("#connectionUsingSecure").prop('checked');
+
// Connect to a print-server instance, if specified
- if(host != "" && host != 'localhost') {
- if(config) {
+ if (host != "" && host != 'localhost') {
+ if (config) {
config.host = host;
config.usingSecure = usingSecure;
} else {
- config = { host: host, usingSecure: usingSecure };
+ config = { host: host, usingSecure: usingSecure };
}
}
+
if (!qz.websocket.isActive()) {
updateState('Waiting', 'default');
@@ -1456,8 +1458,7 @@ Options
qz.networking.devices().then(function(data) {
var list = '';
- var hostname = '';
- var username = '';
+
for(var i = 0; i < data.length; i++) {
var info = data[i];
@@ -1466,8 +1467,8 @@ Options
" Hostname: " + info.hostname + "
" +
"" +
"" +
- " Username: " + info.username + "
"
- "";
+ " Username: " + info.username + "
" +
+ "";
}
list += "" +
" Interface: " + (info.name || "UNKNOWN") + (info.id ? "
(" + info.id + "
)" : "") +
@@ -2407,7 +2408,14 @@ Options
function resetGeneralOptions() {
//connection
$("#connectionHost").val('localhost');
- $("#connectionUsingSecure").prop('disabled', location.protocol !== 'https:');
+
+ var secureOpt = $("#connectionUsingSecure");
+ if (location.protocol !== 'https:') {
+ secureOpt.prop('disabled', true);
+ secureOpt.prop('checked', false);
+ } else {
+ secureOpt.prop('disabled', false);
+ }
}
function resetRawOptions() {
diff --git a/src/qz/ws/PrintSocketClient.java b/src/qz/ws/PrintSocketClient.java
index 25a731e45..7f0457046 100644
--- a/src/qz/ws/PrintSocketClient.java
+++ b/src/qz/ws/PrintSocketClient.java
@@ -6,6 +6,7 @@
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.websocket.api.CloseException;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketException;
import org.eclipse.jetty.websocket.api.annotations.*;
@@ -34,6 +35,7 @@
import java.util.HashMap;
import java.util.Locale;
import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeoutException;
@WebSocket
@@ -82,6 +84,12 @@ public void onClose(Session session, int closeCode, String reason) {
@OnWebSocketError
public void onError(Session session, Throwable error) {
if (error instanceof EOFException) { return; }
+
+ if (error instanceof CloseException && error.getCause() instanceof TimeoutException) {
+ log.error("Timeout error (Lost connection with client)", error);
+ return;
+ }
+
log.error("Connection error", error);
trayManager.displayErrorMessage(error.getMessage());
}