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

Handle PeerNotConnected exceptions when sending wire keep alives #918

Merged
merged 3 commits into from
Feb 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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");
}
}
}