Intermittent error when using mod_proxy to do reverse proxy to SOAP service
I get this error every few minutes when using mod_proxy as a reverse proxy to a SOAP web service. There's probably 3 or 4 requests going per seconds so we're talking around 1 or 2 out of every thousand that have this error.
[Tue Nov 23 11:44:14 2010] [error] [client 172.16.1.31] (20014)Internal error: proxy: error reading status line from remote server soap1.server:8888
[Tue Nov 23 11:44:14 2010] [error] [client 172.16.1.31] proxy: Error reading from remote server returned by /someapp/path/to/web/service
This causes the request to fail. If I have the client connect directly to the soap server without using the proxy, success is 100% so the problem appears to be in the proxy
The configuration looks like this. The purpose is to switch to a backup server if the primary one is unavailable:
<Proxy balancer://apicluster>
BalancerMember http://soap1.server:8888 lbset=0
BalancerMember http://soap2.server:8888 lbset=1
</Proxy>
ProxyPass /someapp balancer://apicluster/someapp
ProxyPassReverse / balancer://apicluster/someapp
Has anyone run into this and found a fix? There's some mentions in bug reports but no solutions. The only thing that may be unusual is the client request could be 100MB or larger, so the request could take a little longer than you'd expect for a SOAP call.
In case someone else runs into this. This is a bug in mod_proxy that can be avoided by putting these lines in your httpd.conf:
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
https://issues.apache.org/bugzilla/show_bug.cgi?id=37770
For info on what these variables do see the mod_proxy
documentation. They have a specific section, Protocol Adjustment, that addresses these variables.
Take note of the Apache documentation here: http://httpd.apache.org/docs/2.2/mod/mod_proxy_http.html
It seems there is a race condition in mod_proxy_http, but it can be avoided by including:
SetEnv proxy-initial-not-pooled 1
Which prevents Apache using a pooled connection if this is an initial request.
The document does note that this setting will give a performance downgrade.