You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Charles So <ch...@mac.com> on 2003/04/27 09:04:34 UTC

SocketException

Hello, I encountered this problem:

java.net.SocketException: Too many open files
          at java.net.PlainSocketImpl.socketAccept(Native Method)
          at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:463)
          at java.net.ServerSocket.implAccept(ServerSocket.java:238)
          at java.net.ServerSocket.accept(ServerSocket.java:217)
          at
org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:268)
          at
org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:
531)
          at
org.apache.jk.common.SocketAcceptor.runIt(ChannelSocket.java:660)
          at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:619)
          at java.lang.Thread.run(Thread.java:491)


I am using DBCP version 1.0 as the connection pool. The webapp is set
to have a maximum of 40 sessions. Connection to MySQL per session is 5.

This exception occured after I took these steps:

1) stress the webapp and make it open 40 sessions
2) let the sessions time out
3) re-stress the webapp again and make it open 40 sessions
4) let it time out again
5) re-stress the webapp			<--- this is where I encounter the
SocketException




How should I handle this? I am using Tomcat 4.1.24, MySQL 3.XX.56,
Connector/J 3.0.7, on Mac OSX 10.2.5 running JDK1.3.1


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: SocketException

Posted by Tim Funk <fu...@joedog.org>.
You are running out of files descriptors. Its a unix thing. A process can 
have only so many files descriptors open at one time. To manipulate late this 
  - use the ulimit command (in sh,bash) to alter the values. Depending on how 
high you want the value set, you may need to be root.

So in startup.sh (or a script which calls startup.sh) you'll need a command 
like this:
ulimit -n 1024      # or whatever number you want there

So get a list of all values:
ulimit -a
and better yet:
man ulimit

An example of ulimit's output (on a plain old linux box that I don't run 
tomcat on - but was the closest available while writing this post, the values 
below might NOT be the ones you want in a server environment):

funkman@fudd: ulimit -a
core file size (blocks)     0
data seg size (kbytes)      unlimited
file size (blocks)          unlimited
max locked memory (kbytes)  unlimited
max memory size (kbytes)    unlimited
open files                  1024
pipe size (512 bytes)       8
stack size (kbytes)         8192
cpu time (seconds)          unlimited
max user processes          320
virtual memory (kbytes)     unlimited


-Tim

Charles So wrote:
> Hello, I encountered this problem:
> 
> java.net.SocketException: Too many open files
>          at java.net.PlainSocketImpl.socketAccept(Native Method)
>          at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:463)
>          at java.net.ServerSocket.implAccept(ServerSocket.java:238)
>          at java.net.ServerSocket.accept(ServerSocket.java:217)
>          at
> org.apache.jk.common.ChannelSocket.accept(ChannelSocket.java:268)
>          at
> org.apache.jk.common.ChannelSocket.acceptConnections(ChannelSocket.java:
> 531)
>          at
> org.apache.jk.common.SocketAcceptor.runIt(ChannelSocket.java:660)
>          at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
> .java:619)
>          at java.lang.Thread.run(Thread.java:491)
> 
> 
> I am using DBCP version 1.0 as the connection pool. The webapp is set
> to have a maximum of 40 sessions. Connection to MySQL per session is 5.
> 
> This exception occured after I took these steps:
> 
> 1) stress the webapp and make it open 40 sessions
> 2) let the sessions time out
> 3) re-stress the webapp again and make it open 40 sessions
> 4) let it time out again
> 5) re-stress the webapp            <--- this is where I encounter the
> SocketException
> 
> 
> 
> 
> How should I handle this? I am using Tomcat 4.1.24, MySQL 3.XX.56,
> Connector/J 3.0.7, on Mac OSX 10.2.5 running JDK1.3.1
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org