@@ -45,22 +45,27 @@ public void connect(String host, int port, String remoteId) {
4545 ChannelFuture f = connectAsync (host , port , remoteId , false );
4646 f .sync ().channel ().closeFuture ().sync ();
4747 } catch (Exception e ) {
48- logger .info ("Can't connect to {}:{}, cause:{})" , host , port , e .getMessage ());
48+ logger .warn ("Can't connect to {}:{}, cause:{})" , host , port , e .getMessage ());
4949 }
5050 }
5151
52- public ChannelFuture connectAsync (NodeHandler nodeHandler , boolean discoveryMode ) {
52+ public void connectAsync (NodeHandler nodeHandler , boolean discoveryMode ) {
5353 Node node = nodeHandler .getNode ();
54- return connectAsync (node .getHost (), node .getPort (), node .getHexId (), discoveryMode )
55- .addListener ((ChannelFutureListener ) future -> {
56- if (!future .isSuccess ()) {
57- logger .warn ("Connect to {}:{} fail, cause:{}" , node .getHost (), node .getPort (),
58- future .cause ().getMessage ());
59- nodeHandler .getNodeStatistics ().nodeDisconnectedLocal (ReasonCode .CONNECT_FAIL );
60- nodeHandler .getNodeStatistics ().notifyDisconnect ();
61- future .channel ().close ();
62- }
63- });
54+ try {
55+ connectAsync (node .getHost (), node .getPort (), node .getHexId (), discoveryMode )
56+ .addListener ((ChannelFutureListener ) future -> {
57+ if (!future .isSuccess ()) {
58+ logger .warn ("Connect to {}:{} fail, cause:{}" , node .getHost (), node .getPort (),
59+ future .cause ().getMessage ());
60+ nodeHandler .getNodeStatistics ().nodeDisconnectedLocal (ReasonCode .CONNECT_FAIL );
61+ nodeHandler .getNodeStatistics ().notifyDisconnect ();
62+ future .channel ().close ();
63+ }
64+ });
65+ } catch (Exception e ) {
66+ logger .warn ("Connect to peer {} failed, reason: {}" ,
67+ node .getHost (), e .getMessage ());
68+ }
6469 }
6570
6671 private ChannelFuture connectAsync (String host , int port , String remoteId ,
0 commit comments