Bamboo SCP task timeout issue
Asked by Joseph Allen:

I'm not sure what changed, but all of a sudden all of my bamboo builds and deployments that have a task for SCP have stopped working. They all generate the below error message. If I go into the OS and manually perform an SCP from the terminal, it works just fine. From bamboo, it hangs for a long time, then fails.

Here's the stacktrace:

```
error	13-Sep-2017 01:58:25	net.schmizz.sshj.transport.TransportException: Connection timed outerror	13-Sep-2017 01:58:25		at net.schmizz.sshj.transport.TransportImpl.write(TransportImpl.java:443)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.flush(ChannelOutputStream.java:111)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.connection.channel.ChannelOutputStream$DataBuffer.write(ChannelOutputStream.java:67)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.connection.channel.ChannelOutputStream.write(ChannelOutputStream.java:148)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.common.StreamCopier.write(StreamCopier.java:149)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.common.StreamCopier.copy(StreamCopier.java:131)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPEngine.transferToRemote(SCPEngine.java:143)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPUploadClient.sendFile(SCPUploadClient.java:98)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPUploadClient.process(SCPUploadClient.java:78)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPUploadClient.startCopy(SCPUploadClient.java:70)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPUploadClient.copy(SCPUploadClient.java:50)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPUploadClient.copy(SCPUploadClient.java:43)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.xfer.scp.SCPFileTransfer.upload(SCPFileTransfer.java:57)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.plugins.scp.ScpTask.transferFiles(ScpTask.java:418)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.plugins.scp.ScpTask.execute(ScpTask.java:284)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.plugins.scp.ScpTask.run(ScpTask.java:127)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.plugins.scp.ScpTask.execute(ScpTask.java:105)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$2(TaskExecutorImpl.java:313)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.task.TaskExecutorImpl$$Lambda$459/1150877339.call(Unknown Source)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:246)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:313)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:118)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:74)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:215)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:139)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:130)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:221)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:129)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:137)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:51)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)error	13-Sep-2017 01:58:25		at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)error	13-Sep-2017 01:58:25		at java.lang.Thread.run(Thread.java:745)error	13-Sep-2017 01:58:25	Caused by: java.net.SocketException: Connection timed outerror	13-Sep-2017 01:58:25		at java.net.SocketOutputStream.socketWrite0(Native Method)error	13-Sep-2017 01:58:25		at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)error	13-Sep-2017 01:58:25		at java.net.SocketOutputStream.write(SocketOutputStream.java:153)error	13-Sep-2017 01:58:25		at net.schmizz.sshj.transport.TransportImpl.write(TransportImpl.java:440)error	13-Sep-2017 01:58:25		... 33 moreerror	13-Sep-2017 01:58:25	Copy Failed. Some files were not uploaded successfully.

Can anyone help me figure out what my issue is???
```


Answers:
author: somethingblue
body: Hi Joseph,

How long does the transfer take over scp? One issue could be the timeout in Tomcat:

In the Standalone version, the Tomcat's `connectionTimeout` value is set to 20000 milliseconds (20 seconds). Depending on your connection speed, if you require to have a connection longer than 20 seconds then you need to increase the value. It's a good idea to consider the geographic location of your users to gauge the suitable length of time.

Please increase the `connectionTimeout` and see if that helps to resolve the issue. Try doubling the timeout to 40 seconds or 40000 millilseconds.

See [Tomcat's documentation](http://tomcat.apache.org/connectors-doc/generic_howto/timeouts.html) on increasing the timeout.

Cheers,

Branden

comments: author: Joseph Allen
body: Over normal SCP from the Linux Consol, it's less than 10 seconds for the transfer to complete.


Tags: app

ssh