Too many open files error with Netty

Albert Strasheim fullung at gmail.com
Fri Oct 16 03:39:31 EDT 2009


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?

Regards,

Albert


More information about the netty-users mailing list