You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James Johnson <jo...@gmail.com> on 2008/01/10 17:59:00 UTC

Opening and Closing Sockets used in Http request and responses

 I have a Spring based application that is running in Tomcat 5.5.12. Tomcat
is integrated with Apache. Apache host JavaScript client side code that
makes Http asynchronous calls to the Spring based application. I'm getting
an error reported from Apache as follows:

Too many open files: apr_accept: (client socket)

There is speculation that the resources being used in the Spring based app.
are not being properly cleaned up. More specifically, the HttpServletRequest
and HttpServletResponse objects are leaving streams and sockets open on the
Apache server. Should I be explicitly closing streams and sockets of the
HttpServletRequest and HttpServletReponse objects? If so, how would this be
done? Or does tomcat handle this?

Here's an example of what is currently is done.

public class Something implements Controller {

public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
//read something from request
doSomething();
return null;
}
}

Re: Opening and Closing Sockets used in Http request and responses

Posted by Bill Barker <wb...@wilshire.com>.
By default, Tomcat and mod_jk leave the Sockets open between them 
indefinitely.  The usual way to work around this is to configure a 
connectionTimeout in the <Connector /> element, and possibly enable 
cping/cpong on the Apache side.  In any case, Tomcat doesn't expose the 
socket to the webapp, so there isn't really anything you can do in your app 
programatically.

Otherwise, pretty much what Giancarlo said :)

"James Johnson" <jo...@gmail.com> wrote in message 
news:be5512460801100859tb99486ey8e669029b8486a48@mail.gmail.com...
> I have a Spring based application that is running in Tomcat 5.5.12. Tomcat
> is integrated with Apache. Apache host JavaScript client side code that
> makes Http asynchronous calls to the Spring based application. I'm getting
> an error reported from Apache as follows:
>
> Too many open files: apr_accept: (client socket)
>
> There is speculation that the resources being used in the Spring based 
> app.
> are not being properly cleaned up. More specifically, the 
> HttpServletRequest
> and HttpServletResponse objects are leaving streams and sockets open on 
> the
> Apache server. Should I be explicitly closing streams and sockets of the
> HttpServletRequest and HttpServletReponse objects? If so, how would this 
> be
> done? Or does tomcat handle this?
>
> Here's an example of what is currently is done.
>
> public class Something implements Controller {
>
> public ModelAndView handleRequest(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
> //read something from request
> doSomething();
> return null;
> }
> }
> 




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Opening and Closing Sockets used in Http request and responses

Posted by Giancarlo Frison <fr...@nimbuzz.com>.
Hi James,

Maybe the webapp clients exceed the maximun allowed by OS. You have to
increase the number of open files for tomcat launch user.
add  
ulimit -n 32000 
into tomcat's launch script.

hope this is helpful


James Johnson ha scritto:
>  I have a Spring based application that is running in Tomcat 5.5.12. Tomcat
> is integrated with Apache. Apache host JavaScript client side code that
> makes Http asynchronous calls to the Spring based application. I'm getting
> an error reported from Apache as follows:
>
> Too many open files: apr_accept: (client socket)
>
> There is speculation that the resources being used in the Spring based app.
> are not being properly cleaned up. More specifically, the HttpServletRequest
> and HttpServletResponse objects are leaving streams and sockets open on the
> Apache server. Should I be explicitly closing streams and sockets of the
> HttpServletRequest and HttpServletReponse objects? If so, how would this be
> done? Or does tomcat handle this?
>
> Here's an example of what is currently is done.
>
> public class Something implements Controller {
>
> public ModelAndView handleRequest(HttpServletRequest request,
> HttpServletResponse response) throws ServletException, IOException {
> //read something from request
> doSomething();
> return null;
> }
> }
>
>   
----
Giancarlo Frison
http://www.jroller.com/giancarlo


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org