Skip to content

Commit ada3df5

Browse files
authored
FIX: Netty: call onDisconnect when crossbar not reachable (#418)
* FIX: Netty: call onDisconnect when crossbar not reachable
1 parent 92736cb commit ada3df5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

autobahn/src/main/java/io/crossbar/autobahn/wamp/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public CompletableFuture<ExitInfo> connect(TransportOptions options) {
127127
try {
128128
mTransports.get(0).connect(mSession, options);
129129
} catch (Exception e) {
130-
throw new CompletionException(e);
130+
exitFuture.completeExceptionally(e);
131131
}
132132
}, getExecutor());
133133
return exitFuture;

autobahn/src/main/java/io/crossbar/autobahn/wamp/transports/NettyWebSocket.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import io.netty.buffer.ByteBuf;
3232
import io.netty.buffer.Unpooled;
3333
import io.netty.channel.Channel;
34+
import io.netty.channel.ChannelFuture;
35+
import io.netty.channel.ChannelFutureListener;
3436
import io.netty.channel.ChannelInitializer;
3537
import io.netty.channel.ChannelPipeline;
3638
import io.netty.channel.EventLoopGroup;
@@ -178,9 +180,15 @@ protected void initChannel(SocketChannel ch) throws Exception {
178180
mHandler);
179181
}
180182
});
181-
182-
mChannel = bootstrap.connect(uri.getHost(), port).sync().channel();
183-
mHandler.getHandshakeFuture().sync();
183+
ChannelFuture f = bootstrap.connect(uri.getHost(), port);
184+
f.addListener((ChannelFutureListener) connectFuture -> {
185+
Throwable connectCause = connectFuture.cause();
186+
if (connectCause != null) {
187+
transportHandler.onDisconnect(false);
188+
} else {
189+
mChannel = f.channel();
190+
}
191+
});
184192
}
185193

186194
@Override

0 commit comments

Comments
 (0)