spurious problem with Client NIOSockets
Neil Avery
neil at liquidlabs.co.uk
Mon May 24 06:05:55 EDT 2010
All,
Trustin - firstly - thanks again for such an awesome network framework - it
has provided to be amazingly scalable for some of the loads we have been
putting through it; 4000 servers streaming GBs of data and its been rock
solid!
Platform Netty 3.2RC1, RedHat Linux, Java 1.6.0_18
Unfortunately we have finally hit a weird issue which only occurs on this
particular platform. Using the NioClientSocketChannelFactory to create a
client, after a period of use we start to experience a timeout when trying
to bind. The code is standard in that it follows the tutorials and we have
never seen this problem before. In this case there is little load on the
system and its only sending messages to 6 peers.
Now for the weird bit - there is no cause excepton() sent to the handler
(our nio listener) and - when printing
the channelFuture.getChannel().getLocalAddress() it prints out a valid
client address. Using lsof & netstat we can see the connection is actually
bound. As part of the failure, we attempt to free resources for the channel
and they also fail to release the bound connection...so we leak connections.
Cleanup is attempted using; closeFuture = channelFuture.getChannel().close()
and then wait 10seconds for the closeFuture to complete.
So I guess I have 3 questions:
- are we handling the connection bind correctly? - it doesnt seem for this
case as it does connect the code doesnt think it has
- are we handling closeDown correctly? - channelFuture.getChannel().close()
doesnt seem to release these resources...
- is there a brute force way to access the underlying socketChannel and
attempt to release it?
Any help appreciated,
Regard Neil.
ClientBootstrap bootstrap = new ClientBootstrap(nettyClientfactory);
handler = new NettyClientHandler(uri);
bootstrap.getPipeline().addLast(HANDLER, handler);
bootstrap.setOption(TCP_NO_DELAY, true);
bootstrap.setOption(KEEP_ALIVE, true);
channelFuture = bootstrap.connect(new InetSocketAddress(uri.getHost(),
uri.getPort()));
try {
boolean success = channelFuture.await(10, TimeUnit.SECONDS);
if (!success) {
if (handler.getException() != null) {
throw new RuntimeException(String.format("%s\n Failed to establish
Connection within %d secs:%s", this.toString(), connectionEstablishTimeout,
uri), handler.getException()); } else { throw new
RuntimeException(String.format("%s\n Failed to establish Connection within
%d secs:%s", this.toString(), connectionEstablishTimeout, uri)); }
--
www.liquidlabs.co.uk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/netty-users/attachments/20100524/f41dc57c/attachment.html
More information about the netty-users
mailing list