diff --git a/core/src/main/java/org/bitcoinj/core/PeerGroup.java b/core/src/main/java/org/bitcoinj/core/PeerGroup.java index 7aaa1ad0bec..483bde03cd9 100644 --- a/core/src/main/java/org/bitcoinj/core/PeerGroup.java +++ b/core/src/main/java/org/bitcoinj/core/PeerGroup.java @@ -588,7 +588,12 @@ public void go() { executor.schedule(this, delay, TimeUnit.MILLISECONDS); return; } - connectTo(addrToTry, false, vConnectTimeoutMillis); + + // BitcoinJ gets too many connections after a connection loss and reconnect as it adds up a lot of + // potential candidates and then try to connect to all of those when getting connection again. + // A check for maxConnections is required to not exceed connections. + if(pendingPeers.size() + peers.size() < maxConnections) + connectTo(addrToTry, false, vConnectTimeoutMillis); } finally { lock.unlock(); }