You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Eugeny N Dzhurinsky <bo...@redwerk.com> on 2006/11/20 14:00:14 UTC
socket closing
Hi there!
I facing REALLY strange issue, and I'm not sure is it related to HttpClient,
or my OS or whatever.
My application starts several threads, which are opening concurrent HTTP
connections to various hosts. Currently there are 10 threads running. The
threads are sharing the same HttpClient/MultiThreadedHttpConnectionManager.
Now, after several hours of work application and overal system freezes: I can
type text, move mouse, but
* DNS isn't resolving anymore
* X windows works strange - I can't open new terminal windows or applications,
but I can use existing ones
* Firefox can't open any page
* top and iostat shows almost no load
after some minutes my application defreezes and my OS/WM start working as
usual - no hangs, applcations/terminal are opening etc.
A friend of mine told me it is possible the socket limit was exceeded, is it
possible? Does HttpClient closes sockets after it used them?
--
Eugene N Dzhurinsky
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: socket closing
Posted by Roland Weber <ht...@dubioso.net>.
Hi Eugeny,
> Okay, as far as I know by sending Connection: close to a server I will force
> the server to close connection after it returns data and return
> Connection: close in response headers as well. In sources I saw HttpClient
> tracks this header as instruction to close underlying connection, am I
> correct if I suppose socket will be closed and released back to OS?
Yes, you are correct.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: socket closing
Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Mon, Nov 20, 2006 at 05:03:08PM +0100, Roland Weber wrote:
> Hello Eugeny,
>
> > So if I specify: params.setMaxTotalConnections(1000); - there could be cases
> > when there are 1000 sockets opened and not closed by HttpClient? And if there
> > are several aplications deployed on the same host, so the number of sockets
> > used could be N*1000?
> Yes, exactly.
Okay, as far as I know by sending Connection: close to a server I will force
the server to close connection after it returns data and return
Connection: close in response headers as well. In sources I saw HttpClient
tracks this header as instruction to close underlying connection, am I
correct if I suppose socket will be closed and released back to OS?
--
Eugene N Dzhurinsky
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: socket closing
Posted by Roland Weber <ht...@dubioso.net>.
Hello Eugeny,
> So if I specify: params.setMaxTotalConnections(1000); - there could be cases
> when there are 1000 sockets opened and not closed by HttpClient? And if there
> are several aplications deployed on the same host, so the number of sockets
> used could be N*1000?
Yes, exactly.
cheers,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: socket closing
Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Mon, Nov 20, 2006 at 04:00:53PM +0100, Roland Weber wrote:
> Hello Eugeny,
>
> > A friend of mine told me it is possible the socket limit was exceeded, is it
> > possible?
>
> Yes it is.
>
> > Does HttpClient closes sockets after it used them?
>
> No it doesn't. It returns connections to the connection manager, which
> will try to keep the socket connection open for reuse with a subsequent
> request. The number of connections in a connection manager is limited
> by the "max connections" parameter. The number of connection managers
> used depends on your application design.
> If you want connections to be closed, send a "Connection:close" header
> with each request, or implement a custom connection manager. Note that
> performance will be degraded if you're hitting the same host frequently.
So if I specify: params.setMaxTotalConnections(1000); - there could be cases
when there are 1000 sockets opened and not closed by HttpClient? And if there
are several aplications deployed on the same host, so the number of sockets
used could be N*1000?
--
Eugene N Dzhurinsky
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: socket closing
Posted by Roland Weber <ht...@dubioso.net>.
Hello Eugeny,
> A friend of mine told me it is possible the socket limit was exceeded, is it
> possible?
Yes it is.
> Does HttpClient closes sockets after it used them?
No it doesn't. It returns connections to the connection manager, which
will try to keep the socket connection open for reuse with a subsequent
request. The number of connections in a connection manager is limited
by the "max connections" parameter. The number of connection managers
used depends on your application design.
If you want connections to be closed, send a "Connection:close" header
with each request, or implement a custom connection manager. Note that
performance will be degraded if you're hitting the same host frequently.
> and I found there are 186 sockets in CLOSE_WAIT state, and this number grows
Well, I'm not a TCP/IP expert. What does CLOSE_WAIT mean? That the
socket has been closed on the client side but not by the server?
Then it's hardly HttpClient's problem.
You should search our mailing list archives for CLOSE_WAIT, because
this discussion comes up every few months. There are some platform
dependencies, if I remember correctly.
hope that helps,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
Re: socket closing
Posted by Eugeny N Dzhurinsky <bo...@redwerk.com>.
On Mon, Nov 20, 2006 at 03:00:14PM +0200, Eugeny N Dzhurinsky wrote:
> A friend of mine told me it is possible the socket limit was exceeded, is it
> possible? Does HttpClient closes sockets after it used them?
OS is: FreeBSD 5.5
I executed this command:
netstat -n -f inet | grep CLOSE_WAIT | wc -l
and I found there are 186 sockets in CLOSE_WAIT state, and this number grows
--
Eugene N Dzhurinsky
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org