diff --git a/src/main/java/org/p2p/solanaj/ws/SubscriptionWebSocketClient.java b/src/main/java/org/p2p/solanaj/ws/SubscriptionWebSocketClient.java index 875b9088..608c8cc4 100644 --- a/src/main/java/org/p2p/solanaj/ws/SubscriptionWebSocketClient.java +++ b/src/main/java/org/p2p/solanaj/ws/SubscriptionWebSocketClient.java @@ -251,7 +251,15 @@ public void onMessage(String message) { public void onClose(int code, String reason, boolean remote) { System.out.println( "Connection closed by " + (remote ? "remote peer" : "us") + " Code: " + code + " Reason: " + reason); - + try { + boolean connected = reconnectBlocking(); + while (!connected) { + Thread.sleep(1000); + connected = reconnectBlocking(); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } } @Override