Too many open files error with Netty

Trustin Lee (이희승) trustin at gmail.com
Fri Oct 16 04:05:34 EDT 2009


Hello Albert,

On Fri, Oct 16, 2009 at 4:39 PM, Albert Strasheim <fullung at gmail.com> wrote:
> Hello all
>
> On Thu, Oct 15, 2009 at 2:08 PM, Albert Strasheim <fullung at gmail.com> wrote:
>> On Wed, Oct 14, 2009 at 12:46 PM, Albert Strasheim <fullung at gmail.com> wrote:
>>> I'm a new Netty user and I'm having some problems with a "Too many
>>> open files" error.
>>> I'm doing some tests with a server based on the Discard example:
>>> Then it starts connecting clients, each of which writes some data and
>>> then closes the connection.
>>> The main thread runs a loop that keeps 15000 client connections alive.
>>> I'm using Netty 3.1.5 on Solaris 10 with JDK 1.6.0_16.
>> I can see 45000 live NioClientSocketChannel instances, when I would
>> expect to see only 15000 (one for each active connection).
>> It seems they are being kept alive by a HashMap called fdToKey which
>> is a field of a class called sun.nio.ch.DevPollSelectorImpl, which I
>> assume is the selector implementation class being used on Solaris.
>> Am I doing something wrong to prevent these NioClientSocketChannels
>> from being closed properly?
>
> I suspect the problem might be related to the writing+close I am doing
> from the channelConnected and channelInterestChanged event handlers.
>
> I looked at the call stacks of some of the worker threads and it seems
> that in some cases, a new client connection would call straight
> through the following chain:
>
> channelConnected
> writeBuffers
> Channel#write
> channelInterestChanged
> writeBuffers
> future.addListener(ChannelFutureListener.CLOSE); (with the last write future)
> Channel#close
>
> Could a scenario like this be causing the selector key not to be
> cancelled properly?

FD leak should not occur at any case.  I will take a look soon.  Does
this issue occur only in Solaris or also in Linux?

Thanks

— Trustin Lee, http://gleamynode.net/



More information about the netty-users mailing list