title: NetConnection.Call.Failed happening sporadically in Flex3/Tomcat/BlazeDS/Spring
body: <p>I have a very large problem. I've written a large app using Flex3/Tomcat/BlazeDS/Spring that has worked very well while developing locally, fine when I deployed to a common dev environment, but then fails very often when deployed to our test environment. </p>
  
  <p>The failures seem to happen most when a remoting request takes a good bit of time (more than 20 seconds). On my dev server, the errors happen, but only when the request takes a very long time (more than 45 seconds). However, the error also occurs seemingly instantly at times (send a request and it fails immediately). Most of the errors also have HTTP Status: 502 on them (Bad Gateway), but some just say HTTP Failed.</p>
  
  <p>I haven't done anything special with BlazeDS other than put the war file in the webapps directory. The application is accessed over https. Remoting calls refer to the server by "destination" only. The tomcat servers on our DEV and TEST instances have identical java arguments (same Xms and Xmx, etc). Below are my relevant files:</p>
  
  <p>services-config.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;services-config&gt;
      &lt;services&gt;
          &lt;default-channels&gt;
             &lt;channel ref="my-secure-amf"/&gt;
          &lt;/default-channels&gt;
      &lt;/services&gt;
      &lt;channels&gt;
          &lt;channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel"&gt;
              &lt;endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/&gt;
              &lt;properties&gt;
                  &lt;add-no-cache-headers&gt;false&lt;/add-no-cache-headers&gt;
              &lt;/properties&gt;
          &lt;/channel-definition&gt;
      &lt;/channels&gt;
  &lt;services-config&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
      ...
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;spring-flex&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/flexContext.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring-flex&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/messagebroker/*&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>flexContext.xml</p>
  
  <pre><code>&lt;!--
      I have component-scan tags here to scan my class files. The Controller I'm using for flex has an annotation on it to define it as a remote destination. Here it is:
      @Controller
      @RemotingDestination(value = "dest", channels="my-secure-amf")
      public class FlexController {
  --&gt;
  
  &lt;bean id="flexExceptionTranslator" class="edu.liberty.zconduct.web.FlexExceptionTranslator" /&gt;
  
  &lt;flex:message-broker&gt;
      &lt;flex:exception-translator ref="flexExceptionTranslator"/&gt;
      &lt;!-- &lt;flex:secured /&gt; Had this previously, but it wasn't working then, either --&gt;
  &lt;/flex:message-broker&gt;
  </code></pre>
  
  <p>I'm near the end of my rope. The error is an app-breaker. Please, please help me if you can.</p>
  
  <p><strong><em>EDIT</em></strong>
  I switched over to http and still get the error. Tomcat is now saying: </p>
  
  <blockquote>
    <p>WARNING: Error sending end packet </p>
    
    <p>java.net.SocketException: Broken pipe</p>
  </blockquote>
  
  <p>I look in my apache log for jk_mod and see some debug information that looks like the request I sent in, and then the following:</p>
  
  <blockquote>
    <p>[debug]
    ajp_send_request::jk_ajp_common.c
    (1592): Resent the request body (432)</p>
    
    <p>[debug]
    jk_shutdown_socket::jk_connect.c
    (681): About to shutdown socket 68</p>
    
    <p>[debug]
    jk_shutdown_socket::jk_connect.c
    (732): Shutdown socket 68 and read 0
    lingering bytes</p>
    
    <p>[info]
    ajp_connection_tcp_get_message::jk_ajp_common.c
    (1150): (myTestServer) can't receive
    the response header message from
    tomcat, network problems or tomcat
    (xx.xx.xx.xx:xxxx) is down (errno=11)</p>
    
    <p>[error] ajp_get_reply::jk_ajp_common.c
    (1962): (myTestServer) Tomcat is down
    or refused connection. No response has
    been sent to the client (yet)</p>
    
    <p>[info] ajp_service::jk_ajp_common.c
    (2447): (myTestServer) sending request
    to tomcat failed (recoverable), 
    (attempt=2)</p>
    
    <p>[error] ajp_service::jk_ajp_common.c
    (2466): (myTestServer) connecting to
    tomcat failed.</p>
    
    <p>[debug]
    ajp_reset_endpoint::jk_ajp_common.c
    (743): (myTestServer) resetting
    endpoint with sd = 4294967295 (socket
    shutdown)</p>
    
    <p>[debug] ajp_done::jk_ajp_common.c
    (2905): recycling connection pool
    slot=0 for worker myTestServer</p>
    
    <p>[info] jk_handler::mod_jk.c (2615):
    Service error=0 for
    worker=myTestServer</p>
  </blockquote>