Detecting connection problems with async server Streaming rpc

22 views
Skip to first unread message

Elhanan Maayan

unread,
Dec 23, 2019, 7:31:01 AM12/23/19
to grpc.io
even though i'm using shaded netty, this seems the only i way i could find to know about any connection problems while using waitForReady, how safe is it to be used ?


final ManagedChannel connectorChannel = NettyChannelBuilder.forAddress(host, 443).sslContext(sslContext).withOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
        .channelFactory(new ChannelFactory<Channel>() {
@Override
public Channel newChannel() {
final NioSocketChannel nioSocketChannel = new NioSocketChannel() {
@Override
public ChannelFuture connect(SocketAddress remoteAddress) {
final ChannelFuture connect = super.connect(remoteAddress);
connect.addListener((GenericFutureListener<ChannelFuture>) channelFuture -> {
final Throwable cause = channelFuture.cause();
if (cause!=null){
cause.printStackTrace();
}
});
return connect;
}
};

return nioSocketChannel;

}
})
.build();

final FirehoseGrpc.FirehoseStub stub = FirehoseGrpc.newStub(connectorChannel).withCallCredentials(getCredentials(apiKey)).withWaitForReady()
Reply all
Reply to author
Forward
0 new messages