You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Coding Horse <zh...@hotmail.com> on 2007/07/25 14:10:03 UTC

Re: java.net.SocketException: Too many files open

My server(non-stop running mina 2.0 for more than a month) died of
"java.net.SocketException: Too many files open" a few days ago.  
I never monitored fd with lsof before. It surprises me now because a few
hours after restarting my server program lsof displayed hundreds of lines
like these:
java    10601 root  527r  FIFO        0,5           2806455 pipe
java    10601 root  528w  FIFO        0,5           2806455 pipe
java    10601 root  529r  0000        0,9        0  2806456 eventpoll
java    10601 root  530r  0000        0,9        0  2806606 eventpoll
java    10601 root  531w  FIFO        0,5           2806724 pipe
java    10601 root  532r  0000        0,9        0  2806725 eventpoll
java    10601 root  533r  FIFO        0,5           2806726 pipe
java    10601 root  534w  FIFO        0,5           2806726 pipe
java    10601 root  535r  0000        0,9        0  2806727 eventpoll

Does it mean that I didn't close sockets correctly? Any hint about how to
narrow down my problem? 

Thanks a lot in advance!

Zhijun


Vinod Panicker wrote:
> 
> On 11/17/06, Trustin Lee <tr...@apache.org> wrote:
>> Hello Karthik,
>>
>> Please send your questions and ideas to dev@mina.apache.org.  You can
>> also
>> subscribe to the mailing list by sending an empty message to
>> dev-subscribe@mina.apache.org.
>>
>> On 11/17/06, Shyamsunder, Karthik <ks...@verisign.com> wrote:
>> >
>> > We are am kind of stuck on a problem and we are looking for some
>> > direction.  We  felt that you may be the right candidate.  We are using
>> > mina 0.9.0 on Java 5 on IBM Linux platform.   Our application seems to
>> run
>> > fine and then after about 30 minues it starts giving "
>> > java.net.SocketException: Too many files open" or
>> "java.net.IOException:
>> > Too many files open" errors.  We have been chasing this problem down
>> for 3
>> > days now.  We have done all the obvious things like increaasing the
>> number
>> > of file descriptors which is set at a ridiculosly high number like
>> 80000 and
>> > no other processes are running in the OS.
>> >
>> > Also, another thing we noticed is that we are getting some Socket
>> connect
>> > exception too before all hell breaks loose.  We are wondering if we are
>> > using Mina incorrectly.  This is because when when I go to
>> /proc/pidid/fd
>> > folder and look at the sockets that are open it is in thousands, but
>> the
>> > netstat does not show that many connections.  Is it possible that we
>> are not
>> > closing something? Is it possible that there is a bug in Mina? I did
>> track
>> > an issue in 0.7.x that you had apparently fixed.
>> >
>> > Your quick response and thoughts and ideas will be well received.
>> >
>>
>> 0.9.0 is way outdated version.  Please upgrade to 1.0.0.  It should fix
>> your
>> problem.
> 
> This looks to me as an fd leak problem. Karthik, are you opening and
> closing sockets in your application? If you are, then it looks like
> you are not closing the sockets correctly. The 'lsof' utility will
> confirm if there is a problem on your side.
> 
> Another thing you want to make sure is that the user under which you
> are running your application has that many open files available to it.
> Just changing system-wide limits does not help. You need to change
> user-specific limits as well.  Use the 'ulimit -a' command to see how
> many open files are permitted for the current user. You would want to
> run the command under the same user as your application.
> 
> As regards upgrading to a newer version, I doubt this was ever a MINA
> problem - I have definitely not come across this in the 0.9 series.
> 
> HTH,
> Vinod.
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-java.net.SocketException%3A-Too-many-files-open-tf2648848s16868.html#a11781367
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.