diff --git a/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java b/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java index 9a275229..da1fe314 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/client/PeerClient.java @@ -67,7 +67,6 @@ public class PeerClient { } catch (Exception e) { logger.debug("Exception: {} ({})", e.getMessage(), e.getClass().getName()); - throw new Error("Disconnnected"); } finally { workerGroup.shutdownGracefully(); } diff --git a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java index f9a03225..2864c551 100644 --- a/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java +++ b/ethereumj-core/src/main/java/org/ethereum/net/p2p/P2pHandler.java @@ -85,6 +85,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { @Override public void channelActive(ChannelHandlerContext ctx) throws Exception { + active = true; msgQueue.activate(ctx); // Send HELLO once when channel connection has been established msgQueue.sendMessage(HELLO_MESSAGE); @@ -97,8 +98,6 @@ public class P2pHandler extends SimpleChannelInboundHandler { logger.info("P2P protocol activated"); worldManager.getListener().trace("P2P protocol activated"); - - active = true; } public boolean isActive(){ @@ -155,6 +154,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { @Override public void channelInactive(ChannelHandlerContext ctx) throws Exception { + logger.info("channel inactive: ", ctx.toString()); active = false; this.killTimers(); } @@ -163,6 +163,7 @@ public class P2pHandler extends SimpleChannelInboundHandler { public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { logger.error(cause.getCause().toString()); super.exceptionCaught(ctx, cause); + active = false; ctx.close(); killTimers(); } @@ -220,8 +221,6 @@ public class P2pHandler extends SimpleChannelInboundHandler { (ShhHandler)ctx.pipeline().get(Capability.SHH); shhHandler.activate(); } - - capInCommon.add(capability); } } @@ -284,8 +283,6 @@ public class P2pHandler extends SimpleChannelInboundHandler { timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (tearDown) cancel(); - - msgQueue.sendMessage(PING_MESSAGE); } }, 2000, 5000);