summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2020-05-19 13:30:23 +0200
committerSimon Rettberg2020-05-19 13:30:23 +0200
commiteec23fd125ff9aae2d2d9997c01581845cebb8b3 (patch)
tree82dbcbb1f5b06cbc4b7098065e49539883977d55 /src
parentTry reusing old connection, even if we don't have a user context (diff)
downloadbwlp-guacamole-ext-eec23fd125ff9aae2d2d9997c01581845cebb8b3.tar.gz
bwlp-guacamole-ext-eec23fd125ff9aae2d2d9997c01581845cebb8b3.tar.xz
bwlp-guacamole-ext-eec23fd125ff9aae2d2d9997c01581845cebb8b3.zip
Better debug spam for connection checks
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java11
-rw-r--r--src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java14
2 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java
index c60db10..5165a9c 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java
@@ -161,11 +161,12 @@ public class AvailableClient implements Cloneable {
if (now < this.lastConnectionCheck) {
this.lastConnectionCheck = 0;
}
- if (now - this.lastConnectionCheck < 2000)
+ if (now - this.lastConnectionCheck < 750)
return this.connectionOk;
for (;;) {
+ String version = null;
try (VncConnection vnc = new VncConnection(this.clientip, 5900)) {
- String version = vnc.handshake();
+ version = vnc.handshake();
if (version == null) {
LOGGER.info("Host " + this.clientip + " doesn't speak RFB protocol");
break;
@@ -173,11 +174,11 @@ public class AvailableClient implements Cloneable {
LOGGER.debug("VNC Version for " + this.clientip + " is " + version);
if (vnc.tryLogin(this.password)) {
LOGGER.info("Connection to " + this + " is OK");
- this.lastConnectionCheck = now;
+ this.lastConnectionCheck = System.currentTimeMillis();
return this.connectionOk = true;
}
} catch (IOException e) {
- LOGGER.info("Connection error VNC @ " + this);
+ LOGGER.info("Connection error VNC (" + version + ") @ " + this);
if (retries-- > 0) {
try {
Thread.sleep(1000);
@@ -190,7 +191,7 @@ public class AvailableClient implements Cloneable {
}
break;
}
- this.lastConnectionCheck = now;
+ this.lastConnectionCheck = System.currentTimeMillis();
this.password = null; // Render invalid, so ConnectionManager::getForUser() doesn't turn into an infinite loop
return this.connectionOk = false;
}
diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java b/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
index 06a7013..0afafd0 100644
--- a/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
+++ b/src/main/java/de/bwlehrpool/bwlp_guac/VncConnection.java
@@ -101,11 +101,15 @@ public class VncConnection implements Closeable {
return true;
}
- private void printError() throws IOException {
- int len = in.readInt();
- byte[] msg = new byte[len];
- in.readFully(msg);
- LOGGER.info(new String(msg, StandardCharsets.ISO_8859_1));
+ private void printError() {
+ try {
+ int len = in.readInt();
+ byte[] msg = new byte[len];
+ in.readFully(msg);
+ LOGGER.info(new String(msg, StandardCharsets.ISO_8859_1));
+ } catch (IOException e) {
+ // Nothing, we're already kinda handling an error, so if we can't fetch the message, ignore
+ }
}
@Override