Skip to content

Commit d157df5

Browse files
authored
closing VST connection after 3 consecutive keepAlive failures (#380)
1 parent 8865ba1 commit d157df5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public abstract class VstConnection<T> implements Connection {
7272
private final Long ttl;
7373

7474
private final Integer keepAliveInterval;
75+
private int keepAliveFailCounter = 0;
76+
7577
private final Boolean useSsl;
7678
private final SSLContext sslContext;
7779

@@ -139,8 +141,15 @@ protected T sendKeepAlive() {
139141
private void keepAlive() {
140142
try {
141143
doKeepAlive();
144+
keepAliveFailCounter = 0;
142145
} catch (Exception e) {
143146
LOGGER.error("Got exception while performing keepAlive request:", e);
147+
keepAliveFailCounter++;
148+
if (keepAliveFailCounter >= 3) {
149+
LOGGER.error("KeepAlive request failed consecutively for 3 times, closing connection now...");
150+
messageStore.clear(new IOException("Connection unresponsive!"));
151+
close();
152+
}
144153
}
145154
}
146155

0 commit comments

Comments
 (0)