diff --git a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java index e9f27c7..0e99351 100644 --- a/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java +++ b/src/main/java/com/github/steveice10/packetlib/tcp/TcpClientSession.java @@ -129,9 +129,14 @@ public void initChannel(Channel channel) { bootstrap.remoteAddress(remoteAddress); bootstrap.localAddress(bindAddress, bindPort); - bootstrap.connect().addListener((future) -> { - if (!future.isSuccess()) { - exceptionCaught(null, future.cause()); + ChannelFuture future = bootstrap.connect(); + if (wait) { + future.sync(); + } + + future.addListener((futureListener) -> { + if (!futureListener.isSuccess()) { + exceptionCaught(null, futureListener.cause()); } }); } catch(Throwable t) {