Bug 42453 - Long (over 5 minutes) request causes error 10060 from mod_proxy_ajp
Summary: Long (over 5 minutes) request causes error 10060 from mod_proxy_ajp
Status: RESOLVED INVALID
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy (show other bugs)
Version: 2.2.4
Hardware: PC Windows XP
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-18 12:44 UTC by Tim Schafer
Modified: 2008-02-07 12:29 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Schafer 2007-05-18 12:44:06 UTC
A request which takes longer than 5 minutes for tomcat to return a response
causes apache to return a 503 error to client while logging the following error:
[Fri May 18 11:32:36 2007] [error] (OS 10060)A connection attempt failed because
the connected party did not properly respond after a period
 of time, or established connection failed because connected host has failed to
respond.  : ajp_ilink_receive() can't receive header
[Fri May 18 11:32:36 2007] [error] ajp_read_header: ajp_ilink_receive failed
[Fri May 18 11:32:36 2007] [error] (120006)APR does not understand this error
code: proxy: send body failed to (null) (*)

apache mod_proxy_ajp is configured to proxy requests to tomcat
with this addition to httpd.conf:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /webapp ajp://localhost/webapp


apache documentation implies there is no timeout for proxy requests.
http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

If timeout is hardcoded, then a request to enhance with a conf option
If timeout is adjustable, then a request to update documentation with mention of
default timeout and conf option for changing

Very enthused about upgrading from apache 2.0/mod_jk2 to apache 2.2/mod_proxy_ajp
This is the only known blocker to going live.

Great work integrating AJP into apache httpd. Much easier to use :)
Comment 1 Ruediger Pluem 2007-05-18 14:34:20 UTC
1. Timeout is adjustable (=> Timeout parameter at
http://httpd.apache.org/docs/2.2/en/mod/mod_proxy.html#proxypass,
ProxyPass /webapp ajp://localhost/webapp timeout=1800 )
2. It is documented, but the documentation might be misleading (=>
http://httpd.apache.org/docs/2.2/en/mod/mod_proxy.html#proxypass)
Comment 2 Dennis Kieselhorst 2007-08-22 11:32:53 UTC
I have similar problems with my application. If there is a high request count,
the client will get a 503 error. I have two apaches (accessed by round robin
dns) and two tomcats. So if one of them fails, the other one should handle the
requests. Unfortunately this doesn't work, both fail at the same time :-(

The apache error log shows the following:
[error] ajp_read_header: ajp_ilink_receive failed
[error] (120006)APR does not understand this error code: proxy: send body failed
to (null) (x.x.x.x)
[error] (70007)The timeout specified has expired: ajp_ilink_receive() can't
receive header

The tomcat logs contain broken pipe errors and IOExceptions, but I found in
#38489 that this is the expected behaviour.
org.apache.jk.core.MsgContext action
WARNING: Error sending end packet
java.net.SocketException: Broken pipe
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
        at org.apache.jk.common.ChannelSocket.send(ChannelSocket.java:531)
       
Aug 17, 2007 1:12:44 PM org.apache.jk.common.ChannelSocket processConnection
WARNING: processCallbacks status 2

 java.io.IOException
        at org.apache.jk.common.JkInputStream.receive(JkInputStream.java:190)
        at org.apache.jk.common.JkInputStream.doRead(JkInputStream.java:164)
        at org.apache.coyote.Request.doRead(Request.java:418)
        at
org.apache.catalina.connector.InputBuffer.realReadBytes(InputBuffer.java:284
)
        at org.apache.tomcat.util.buf.ByteChunk.substract(ByteChunk.java:371)
        at org.apache.catalina.connector.InputBuffer.readByte(InputBuffer.java:293)
        at
org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:
104)


The issue #36495 deals with similar problems. So I tried to set MaxClients to
512 and keepalive=On (without success). Tomcat maxThreads is 1024.

-- start of my config --
ServerLimit 1024
MaxClients 1024
KeepAlive On
KeepAliveTimeout 5
MaxKeepAliveRequests 20
<IfModule mod_proxy.c>
  ProxyRequests Off
  ProxyTimeout 60
  <Location /instance0>
     ProxyPass balancer://instance0 stickysession=JSESSIONID
lbmethod=byrequests
  </Location>
  
  <Proxy balancer://instance0>
     BalancerMember ajp://[host1-ip]:20009/instance0 route=node1 min=2 smax=5
     BalancerMember ajp://[host2-ip]:20009/instance0 route=node2 min=2 smax=5
  </Proxy>

  <Location /instance1>
      ProxyPass balancer://b2binstance1 stickysession=JSESSIONID lbmethod=byrequests
  </Location>

  <Proxy balancer://instance1>
      BalancerMember ajp://[host1-ip]:21009/instance1 route=node1 min=2 smax=5
      BalancerMember ajp://[host2-ip]:21009/instance1 route=node2 min=2 smax=5
  </Proxy>
</IfModule>
-- config end --

It's exasperating...hope that somebody can give me a hint.

environment: Apache 2.2.4, SunOS 5.8, Tomcat 5.5.20, JDK 1.5
Comment 3 Ruediger Pluem 2007-08-22 12:28:40 UTC
Try adding an explicit timeout parameter to your BalancerMembers. ProxyTimeout
application is broken in 2.2.4 but will be fixed in the next 2.2.x release.
Comment 4 Dennis Kieselhorst 2007-08-23 04:51:51 UTC
Thanks for the quick response. Here's the new config, I'll try now:

<Location /b2b-instance0>
   ProxyPass balancer://b2binstance0 stickysession=JSESSIONID
lbmethod=byrequests timeout=60
</Location>

<Proxy balancer://b2binstance0>
   BalancerMember ajp://212.6.120.198:20009/b2b-instance0 route=node1 min=2
smax=5 timeout=60
   BalancerMember ajp://212.6.120.199:20009/b2b-instance0 route=node2 min=2
smax=5 timeout=60
</Proxy>
Comment 5 Ruediger Pluem 2007-08-23 09:13:40 UTC
(In reply to comment #4)
> Thanks for the quick response. Here's the new config, I'll try now:
> 
> <Location /b2b-instance0>
>    ProxyPass balancer://b2binstance0 stickysession=JSESSIONID
> lbmethod=byrequests timeout=60

The timeout parameter for a balancer has a different meaning that you might not
desire (http://httpd.apache.org/docs/2.2/en/mod/mod_proxy.html#proxypass). So I
would omit it here.

Comment 6 Dennis Kieselhorst 2007-09-04 01:13:46 UTC
Ok seems to be better than before...now only one Apache had problems to connect
to the tomcats. The other one was fine.

After a graceful restart, found this many times in error log:
(9)Bad file number: apr_socket_accept: (client socket)
Comment 7 William A. Rowe Jr. 2007-12-30 23:18:16 UTC
"(9)Bad file number: apr_socket_accept: (client socket)"

indicative of something bogus in the socket stack, such as the host of various
'web filtering' products that weren't completely implemented for the ws2api.

Please confirm that a clean machine (no extra network drivers) does not have
this issue; in the interim, closing as a config/socket stack mistake.
Comment 8 Dennis Kieselhorst 2007-12-31 03:32:32 UTC
After months of testing I switched to http to avoid the problem. It's a pity 
that mod_proxy_ajp doesn't work as stable as mod_jk before.
Comment 9 Tim Schafer 2008-02-06 18:38:37 UTC
Revisiting this problem with an installation from
apache_2.2.8-win32-x86-openssl-0.9.8g.msi

I've found that using:
ProxyPass /webapp ajp://localhost/webapp timeout=1800
Doesn't have the desired effect.

However adding:
Timeout 1800
to httpd.conf will result in allowing a longer running tomcat request to
successfully return it's result, regardless of whether timeout=1800 was added to
the ProxyPass

Is there any way to configure apache to allow a ProxyPass to run longer than the
standard Timeout without overriding it for the entire URL space?
Comment 10 Ruediger Pluem 2008-02-07 12:29:09 UTC
(In reply to comment #9)
> Revisiting this problem with an installation from
> apache_2.2.8-win32-x86-openssl-0.9.8g.msi
> 
> I've found that using:
> ProxyPass /webapp ajp://localhost/webapp timeout=1800
> Doesn't have the desired effect.
> 

I cannot reproduce this. It works and has the desired effect. It is likely that
the worker ajp://localhost/webapp is not used. Do you have any other ProxyPass
settings, <proxy> blocks or rewrite rules in your configuration?