Cannot copy large Artifacts [502 Bad Gateway]

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

Able to copy small artifacts but it fails when large artifacts come into place.

The following appears in the atlassian-bamboo.log:

2015-01-13 12:17:13,902 INFO [2-BAM::172.20.10.54::Agent:pool-5-thread-1] [ExecuteBuildTask] Running post build plugin 'Artifact Copier'
2015-01-13 12:17:13,903 INFO [2-BAM::172.20.10.54::Agent:pool-5-thread-1] [BuildArtifactPostProcessor] Copying the build artifacts for build: PROJ-PLAN-JOB1-1
2015-01-13 12:17:41,093 ERROR [2-BAM::172.20.10.54::Agent:pool-5-thread-1] [BambooPluginUtils] Unable to publish artifact Shared artifact: [MyArtifact], pattern: [Artifact*.zip] anchored at: [.] for PROJ-PLAN-JOB1-1 via com.atlassian.bamboo.build.artifact.BambooRemoteArtifactHandler@2f778b7e
java.lang.RuntimeException: java.io.IOException: Unexpected HTTP status code: HTTP/1.1 502 Bad Gateway
	at com.atlassian.bamboo.v2.build.agent.remote.sender.HttpMessageSender.send(HttpMessageSender.java:131)
	at com.atlassian.bamboo.build.artifact.BambooRemoteArtifactHandler.publish(BambooRemoteArtifactHandler.java:40)
	at com.atlassian.bamboo.build.artifact.AbstractArtifactManager$2.call(AbstractArtifactManager.java:254)
	at com.atlassian.bamboo.build.artifact.AbstractArtifactManager$2.call(AbstractArtifactManager.java:247)
	at com.atlassian.bamboo.plugin.BambooPluginUtils.callUnsafeCode(BambooPluginUtils.java:87)
	at com.atlassian.bamboo.build.artifact.AbstractArtifactManager.publishFileSet(AbstractArtifactManager.java:246)
	at com.atlassian.bamboo.build.artifact.AbstractArtifactManager.publish(AbstractArtifactManager.java:146)
	at com.atlassian.bamboo.build.artifact.BuildArtifactPostProcessor.call(BuildArtifactPostProcessor.java:84)
	at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.performCustomBuildProcess(ExecuteBuildTask.java:159)
	at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:80)
	at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:188)
	at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:112)
	at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:110)
	at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)
	at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)
	at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)
	at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)
	at java.lang.Thread.run(Thread.java:695)
Caused by: java.io.IOException: Unexpected HTTP status code: HTTP/1.1 502 Bad Gateway
	at com.atlassian.bamboo.v2.build.agent.remote.sender.HttpMessageSender.send(HttpMessageSender.java:125)
	... 17 more

Workaround

  • Check/configure timeout in Apache's httpd.conf

    # Configuring the timeout
    Timeout 2400
    ProxyTimeout 2400
    
    # Configuring the reverse proxy
    ProxyPass /CONTEXT http://localhost:8085/CONTEXT
    ProxyPassReverse /CONTEXT http://localhost:8085/CONTEXT
  •  It might be the case where adding the timeout above will provide you with the following error in Apache logs:

    (103)Software caused connection abort: proxy: pass request body failed

    The error above is caused by a malformed server response and, to ignore it, we could set the following option on our httpd.conf:

    ProxyBadHeader Ignore
    

    After adding the above, you should expect the real error being thrown:

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Read timed out
  • You are able to update Tomcat's connect under <bamboo-install>/conf/server.xml. 
    Tomcat has a setting called disableUploadTimeout, which is set as true by default and you have to set it false if you want the timeout to be longer for uploads. Please, refer to Apache - Standard Implementation for further information. 

    # Added the following attributes:
    #   connectionUploadTimeout="36000000"                    
    #   disableUploadTimeout="false"
    #   connectionTimeout="60000"
    #
    # resulting on:
    
    <Connector port="8085"
       maxThreads="150"
       minSpareThreads="25"
    
       enableLookups="false"
       maxHttpHeaderSize="8192"
       protocol="HTTP/1.1"
       useBodyEncodingForURI="true"
       redirectPort="8443"
       acceptCount="100"
       disableUploadTimeout="true"
       
       connectionUploadTimeout="36000000"                    
       disableUploadTimeout="false"
       connectionTimeout="60000"
    />

Reference: 502 Proxy Error / Uploading from Apache (mod_proxy) to Tomcat 7

Last modified on Mar 30, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.