Skip to content

Commit 4025ede

Browse files
add sleeping
1 parent 8c5069c commit 4025ede

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/io/nats/client/impl/NatsConnection.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ void reconnectImpl() throws InterruptedException {
379379
}
380380

381381
writer.setReconnectMode(true);
382+
Thread.sleep(2);
382383

383384
if (!isConnected() && !isClosed() && !this.isClosing()) {
384385
boolean keepGoing = true;
@@ -762,6 +763,7 @@ void closeSocket(boolean tryReconnectIfConnected, boolean forceClose) throws Int
762763

763764
statusLock.lock();
764765
try {
766+
Thread.sleep(1);
765767
updateStatus(Status.DISCONNECTED);
766768
this.exceptionDuringConnectChange = null; // Ignore IOExceptions during closeSocketImpl()
767769
this.disconnecting = false;
@@ -1059,6 +1061,11 @@ void sendUnsub(NatsSubscription sub, int after) {
10591061
if (after > 0) {
10601062
bab.append(SP).append(after);
10611063
}
1064+
try {
1065+
Thread.sleep(1, 500_000);
1066+
} catch (InterruptedException e) {
1067+
throw new RuntimeException(e);
1068+
}
10621069
queueInternalOutgoing(new ProtocolMessage(bab));
10631070
}
10641071

0 commit comments

Comments
 (0)