• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.net.SocketException: Too many open files

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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: java.net.SocketException: Too many open files
at com.jcraft.jsch.Util.createSocket(Util.java:386)
at com.jcraft.jsch.Session.connect(Session.java:186)
at com.jcraft.jsch.Session.connect(Session.java:154)
----------

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?

 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic