Reputation: 1434
I am using netty to write a client application and I'd like to set a connection timeout per connection. Right now I am doing something like:
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(new EpollEventLoopGroup(1)).channel(EpollSocketChannel.class);
bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeoutSecs * 1000);
bootstrap.handler(new EmptyChannelInitializer());
This seems to work globally, but is there a way to specify something per connection? I didn't see any chance to do that in the bootstrap.connect()
method.
Upvotes: 1
Views: 765
Reputation: 23567
You could just set it in the initChannel(...)
method via channel.config().setOption(...)
or just create a new bootstrap (which can share the same EventLoopGroup
.
Upvotes: 2