1

My English is like 3years old baby.

Recently, I made a website with Many File Access.

Unfortunately, My tomcat gave me this following error message

Fatal: Socket accept failed
java.net.SocketException: Too many open files
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:408)
        at java.net.ServerSocket.implAccept(ServerSocket.java:462)
        at java.net.ServerSocket.accept(ServerSocket.java:430)
        at org.apache.tomcat.util.net.DefaultServerSocketFactory.acceptSocket(DefaultServerSocketFactory.java:61)
        at org.apache.tomcat.util.net.JIoEndpoint$Acceptor.run(JIoEndpoint.java:352)
        at java.lang.Thread.run(Thread.java:662)
org.apache.tomcat.util.net.JIoEndpoint$Acceptor run

This happens when I send request in short time, I guess there too many stream opened for this job.

Does anybody know how to solve this problem.

My Environment are { tomcat 6.0.35, java 1.6.0_31, centos 5 } Ah, This only happens on Linux;

thank you.

jeon
  • 113
  • 1
  • 3
  • 15

2 Answers2

0

It's quite possible that you are exceeding the default maximum number of file descriptor.

Explanation and how to increase the values:

http://honglus.blogspot.com.au/2010/08/tune-max-open-files-parameter-in-linux.html http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/

moodywoody
  • 2,049
  • 1
  • 17
  • 20
0

Check the limit allocated by the system cat /proc/sys/fs/file-nr

(last number)

Allocate more if needed

Edit /etc/sysctl.conf

Add/change fs.file-max = xxxxx

Apply changes sysctl -p

Check cat /proc/sys/fs/file-max

You may also have user limits set.

Bruno Grieder
  • 25,347
  • 7
  • 64
  • 97