Java – Error with an Apache in front of Tomcat using AJP connector and mod_proxy


I've a Apache Server (Server version: Apache/2.2.22 (Ubuntu)) in front of a set of three tomcat6 servers. Apache is set up as a load balancer using mod_proxy and the AJP connector:

<VirtualHost *:80>
    ProxyRequests off        
<Proxy balancer://mycluster>
    BalancerMember ajp://localhost:8009 keepalive=On retry=1 timeout=15 ping=1
    BalancerMember ajp:// keepalive=On retry=1 timeout=15 ping=1
    BalancerMember ajp:// keepalive=On retry=1 timeout=1 ping=15

    Order Deny,Allow
    Deny from none
    Allow from all
    ProxySet lbmethod=byrequests

    <Location /balancer-manager>
            SetHandler balancer-manager 
            Order deny,allow
            Allow from all

    ProxyPass /balancer-manager !
    ProxyPass / balancer://mycluster/

Tomcat is running with the following JAVA_OPTS:

-Xms2048m -Xmx2048m -XX:NewSize=256m 
-XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m

The system works fine, however after a while I receive these errors from Tomcat:

org.apache.jk.common.ChannelSocket processConnection 
WARNING: processCallbacks status 2

And this one from Apache:

[error] ajp_read_header: ajp_ilink_receive failed
[error] (70007)The timeout specified has expired: proxy: read response failed from (localhost)
[error] (70007)The timeout specified has expired: ajp_ilink_receive() can't receive header

I have to restart Tomcat to make it works again.

Any idea about what's happening??? After googling for a while it seems that this's a pretty common issue, however I didn't find a proper solution.

Thanks for your help!

Best Solution

Depends a bit what the situation is - a very common cause is harmless; see:

i.e. apache closing out as the client (browser) has closed the TCP connection and that all having propagated through before tomcat has sent its reply down the internal TCP socket.

So I'd up the log level to confirm it - and then scale it down appropriately for production.