views:

133

answers:

2

What does this do in netty?

bootstrap.setOption("child.connectTimeoutMillis", x);
A: 

public void setOption(String key, Object value)

Sets an option with the specified key and value. If there's already an option with the same key, it is replaced with the new value. If the specified value is null, an existing option with the specified key is removed. To set the option value of a child Channel, prepend "child." to the option name (e.g. "child.keepAlive").

Parameters:

key - the option name

value - the option value

And bootstrap.setOption("child.connectTimeoutMillis", x); sets the Connect timeout of the channel(in this case child's channel) in milliseconds. If you set the value to 0, it disables the Timeout Option.

GK
Actually, you have to omit the "child." prefix because connect timeout is a client side option and TCP/IP client channel factory creates a channel without a parent.
Trustin Lee
So that means if I'm writing a server, this option is useless for me? What option do I need to keep all my clients persisted forever (no time out)?
erotsppa
A: 

"child.connectionTimeoutMillis" won't do anything, neither for ClientBootstrap nor for ServerBootstrap.

It's a client option so it should be used only as "connectionTimeoutMillis" (without the "child." part) on ClientBootstrap instances.

What option do I need to keep all my clients persisted forever (no time out)?

Use "child.keepAlive" for ServerBootstrap and "keepAlive" for ClientBootstrap.

brunodecarvalho