This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Too many open files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark " Too many open files" Watch " Too many open files" New topic
Author Too many open files

vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 80
In my application, that deployed at linux, i need to open 30000-40000 sockets on virtual interfaces using threads.

I will get that exception after some time

com.jcraft.jsch.JSchException: Too many open files
at com.jcraft.jsch.Util.createSocket(
at com.jcraft.jsch.Session.connect(
at com.jcraft.jsch.Session.connect(

I tried many system configuration like sysctl, ulimit and I also tried some java option like -Xms1024m -Xmx4096m -XX:MaxPermSize=2048m -XX:ThreadStackSize=4000
but i never get rid of that exceptions.

This exception has great impact on my application.

Please suggest me what should i do?

Tim Moores

Joined: Sep 21, 2011
Posts: 2409
"Too many open files" is not a memory problem. 30000 open sockets will likely be a problem; are you really anticipating that many *simultaneous* connections?

You can increase the maximum number of open files using the "ulimit" command; it's a common thing to do on servers, although not that many.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20128

If you really need 30,000 concurrent connections that sure is going to be one heck of a server. If you don't need them concurrently but overall, the problem may be you forgetting to close all connections when you're done with them.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Too many open files
It's not a secret anymore!