Handle PeerNotConnected exceptions when sending wire keep alives. (#918)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
Adrian Sutton 6 years ago committed by GitHub
parent e279f1f726
commit 72581162d2
  1. 11
      ethereum/p2p/src/main/java/tech/pegasys/pantheon/ethereum/p2p/netty/WireKeepAlive.java

@ -13,6 +13,7 @@
package tech.pegasys.pantheon.ethereum.p2p.netty;
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection;
import tech.pegasys.pantheon.ethereum.p2p.api.PeerConnection.PeerNotConnected;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.DisconnectMessage.DisconnectReason;
import tech.pegasys.pantheon.ethereum.p2p.wire.messages.PingMessage;
@ -54,8 +55,12 @@ final class WireKeepAlive extends ChannelDuplexHandler {
return;
}
LOG.debug("Idle connection detected, sending Wire PING to peer.");
connection.send(null, PingMessage.get());
waitingForPong.set(true);
try {
LOG.debug("Idle connection detected, sending Wire PING to peer.");
connection.send(null, PingMessage.get());
waitingForPong.set(true);
} catch (final PeerNotConnected ignored) {
LOG.trace("PING not sent because peer is already disconnected");
}
}
}

Loading…
Cancel
Save