ws-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Byron Poschwatta <byron.poschwa...@gmail.com>
Subject XML-RPC - Problem with http redirect to a different host
Date Tue, 18 Jan 2011 22:11:32 GMT
I'm using XmlRpcClient (3.1.3) with the XmlRpcCommonsTransportFactory
because I need support for http redirects on my XML-RPC calls. I am
configuring the transport factory to use a Commons HttpClient with a
MultiThreadedHttpConnectionManager in order to pool connections. After some
testing, I discovered that the first couple calls to XmlRpcClient.execute
work fine (handling the redirect included), but after that they start
failing with the following underlying error:

org.apache.commons.httpclient.ConnectionPoolTimeoutException: Timeout
waiting for connection

Looking at the debug log output from the Commons HttpClient library, it
appears that for each XmlRpcClient execute request, the connection to the
first host (the one sending back the redirect) is never released back to the
connection pool, while the connection to the second host (the one that
actually sends the XML-RPC response) is properly released back into the
connection pool. After enough requests to reach the MaxConnectionsPerHost
property of the connection pool (2 by default), there are no more available
connections to the first host for subsequent requests.

I'm not sure if XmlRpcClient is designed to work with redirects to a
different host, but any suggestions for how to get around this issue would
be appreciated. I had a quick look at the source for
org.apache.xmlrpc.client.XmlRpcCommonsTransport and I wonder if the
resetClientForRedirect() method should be releasing the original connection
if the host changes with the redirect?

I can provide a simple sample class that reproduces the problem if that
would be helpful. Also, here is the debug output from the Commons HttpClient
module that I mentioned above:

-----
## Note: I changed the MaxConnectionsPerHost property to 1 so this trial
would fail on the 2nd XML-RPC call.
## Call 1
2011-01-12 16:24:20,953 DEBUG
org.apache.commons.httpclient.params.DefaultHttpParams Set parameter
http.protocol.version = HTTP/1.1
2011-01-12 16:24:20,959 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
HttpConnectionManager.getConnection:  config = HostConfiguration[host=
http://10.0.0.93], timeout = 3000
2011-01-12 16:24:20,960 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Allocating
new connection, hostConfig=HostConfiguration[host=http://10.0.0.93]
2011-01-12 16:24:20,962 DEBUG org.apache.commons.httpclient.HttpConnection
Open connection to 10.0.0.93:80
2011-01-12 16:24:20,969 DEBUG org.apache.commons.httpclient.HttpMethodBase
Adding Host request header
2011-01-12 16:24:20,976 DEBUG
org.apache.commons.httpclient.methods.EntityEnclosingMethod Request body
sent
2011-01-12 16:24:20,988 DEBUG
org.apache.commons.httpclient.HttpMethodDirector Redirect required
2011-01-12 16:24:20,988 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
HttpConnectionManager.getConnection:  config = HostConfiguration[host=
http://10.0.0.94], timeout = 3000
2011-01-12 16:24:20,988 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Allocating
new connection, hostConfig=HostConfiguration[host=http://10.0.0.94]
2011-01-12 16:24:20,988 DEBUG org.apache.commons.httpclient.HttpConnection
Open connection to 10.0.0.94:80
2011-01-12 16:24:20,989 DEBUG org.apache.commons.httpclient.HttpMethodBase
Adding Host request header
2011-01-12 16:24:20,990 DEBUG
org.apache.commons.httpclient.methods.EntityEnclosingMethod Request body
sent
2011-01-12 16:24:21,079 DEBUG org.apache.commons.httpclient.HttpMethodBase
Should close connection in response to directive: close
2011-01-12 16:24:21,079 DEBUG org.apache.commons.httpclient.HttpConnection
Releasing connection back to connection manager.
2011-01-12 16:24:21,079 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Freeing
connection, hostConfig=HostConfiguration[host=http://10.0.0.94]
2011-01-12 16:24:21,079 DEBUG
org.apache.commons.httpclient.util.IdleConnectionHandler Adding connection
at: 1294874661079
2011-01-12 16:24:21,079 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Notifying
no-one, there are no waiting threads
## Call 2
2011-01-12 16:24:21,152 DEBUG
org.apache.commons.httpclient.params.DefaultHttpParams Set parameter
http.protocol.version = HTTP/1.1
2011-01-12 16:24:21,153 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
HttpConnectionManager.getConnection:  config = HostConfiguration[host=
http://10.0.0.93], timeout = 3000
2011-01-12 16:24:21,153 DEBUG
org.apache.commons.httpclient.MultiThreadedHttpConnectionManager Unable to
get a connection, waiting..., hostConfig=HostConfiguration[host=
http://10.0.0.93]
-----

Thanks in advance for any help you can provide.

Sincerely,

Byron Poschwatta

Mime
View raw message