Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
Handle PeerNotConnected exceptions when sending wire keep alives. (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton committed Feb 20, 2019
1 parent f73b4e8 commit 38edb0f
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -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;

Expand Down Expand Up @@ -54,8 +55,12 @@ public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt
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");
}
}
}

0 comments on commit 38edb0f

Please sign in to comment.