Hi Folks,
Im hope some one can shed some light on this for me. Im currently doing a
prototype and decided i would do it with the httpclient4.0 alpha3 version. I
have or will have a multi-threaded scenario so i have a very similar set up as
the ClientMultiThreadedExecution example located here
http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java
Anyways i have the use case that should my server go down, my app will wait
till it comes back up. So i have a worker thread that polls the server or tries
to poll the server every 30 seconds. Now i re-use the same httpclient instance
right throughout the whole application
Now what i see in the log file is as follows
18203 [Thread-1] DEBUG org.apache.http.impl.client.ClientParamsStack -
'http.protocol.max-redirects': null
18203 [Thread-1] DEBUG org.apache.http.impl.client.ClientParamsStack -
'http.connection-manager.timeout': null
18203 [Thread-1] DEBUG
org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager -
ThreadSafeClientConnManager.getConnection:
HttpRoute[{}->http://localhost:8080], timeout = 0
18203 [Thread-1] DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute - No
free connections. HttpRoute[{}->http://localhost:8080]
18203 [Thread-1] DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Need
to wait for connection. HttpRoute[{}->http://localhost:8080]
My problem is that the client just hangs and i think it is due to the "Need to
wait for connection" part.
18203 [Thread-1] DEBUG org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Need
to wait for connection. HttpRoute[{}->http://localhost:8080]
How long does a thread wait until it gets a free connection?? infinity?? Or how
is it released?? My polling thread is just hanging. I restart the server but
the polling thread is still waiting/hanging.
I have taken the same scenario and used the http client 3.1 and have no
problems like above.
I think i read somewhere that the connection is returned back to the pool when
the input stream is closed. Now if the server is down, i dont get a response
input stream, so does the httpget.abort release the connection back to the
pool? I dont think it has anything to do with the TIME_WAIT state either, once
the thread enters the "need to wait for connection" it will hang for infinity.
I tried to get a hold of the current threads connection but the API doesnt give
me that chance, just so i could close the connection myself and not be
dependant on whats underneath to clean up.
Anybody any input as to why my polling thread just hangs in a wait state for
infinity??
Cheers,
JB
_________________________________________________________________
Love Hotmail? It just got better – Drag and Drop capabilities, new Reading
Panes making it easier to read your mail, enhanced security settings, 5GB of
FREE storage? New Windows Live Hotmail. Get your free account here
http://get.live.com/mail/overview/