[PROTOCOL_ERROR] Received CHANNEL_SUCCESS on unknown channel
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Problem
When using a SSH task, the task always fail with the following error in the build logs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
net.schmizz.sshj.connection.ConnectionException: Timeout expiredat net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:32)
at net.schmizz.sshj.connection.ConnectionException$1.chain(ConnectionException.java:26)
at net.schmizz.concurrent.Promise.retrieve(Promise.java:139)
at net.schmizz.concurrent.Event.await(Event.java:103)
at net.schmizz.sshj.connection.channel.direct.SessionChannel.exec(SessionChannel.java:102)
at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:124)
at com.atlassian.bamboo.task.TaskExecutorImpl$3.call(TaskExecutorImpl.java:281)
at com.atlassian.bamboo.task.TaskExecutorImpl$3.call(TaskExecutorImpl.java:278)
at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:198)
at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:278)
at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:105)
at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:75)
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:745)
Caused by: java.util.concurrent.TimeoutException: Timeout expired
... 18 more
Error occurred while running Task 'Undeploy / deploy(2)' of type com.atlassian.bamboo.plugins.bamboo-scp-plugin:sshtask.
com.atlassian.bamboo.task.TaskException: SSH command failed
at com.atlassian.bamboo.plugins.scp.SshTask.execute(SshTask.java:145)
at com.atlassian.bamboo.task.TaskExecutorImpl$3.call(TaskExecutorImpl.java:281)
at com.atlassian.bamboo.task.TaskExecutorImpl$3.call(TaskExecutorImpl.java:278)
at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:198)
at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:278)
at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:105)
at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:75)
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:745)
The following appears in the atlassian-bamboo.log
1
2
3
4
5
6
7
8
9
2015-04-23 19:28:18,369 ERROR [reader] [TransportImpl] Dying because - {}
net.schmizz.sshj.connection.ConnectionException: [PROTOCOL_ERROR] Received CHANNEL_SUCCESS on unknown channel #0
at net.schmizz.sshj.connection.ConnectionImpl.getChannel(ConnectionImpl.java:117)
at net.schmizz.sshj.connection.ConnectionImpl.handle(ConnectionImpl.java:128)
at net.schmizz.sshj.transport.TransportImpl.handle(TransportImpl.java:455)
at net.schmizz.sshj.transport.Decoder.decode(Decoder.java:107)
at net.schmizz.sshj.transport.Decoder.received(Decoder.java:175)
at net.schmizz.sshj.transport.Reader.run(Reader.java:61)
2015-04-23 19:28:18,370 INFO [reader] [TransportImpl] Disconnected - PROTOCOL_ERROR
Diagnosis
Environment
This issue is known to happen when using SSH Task to connect with JBoss Fuse server
Cause
This issue is caused by a protocol ambiguity in SSH: http://comments.gmane.org/gmane.ietf.secsh/7003
When using SSHj with Apache SSHD, the CHANNEL_SUCCESS
is not expected after CHANNEL_CLOSE
. After enabling ALL logging onnet.schmizz.sshj
, the following can be seen in the logs:
1
2
3
4
5
6
7
8
9
2015-04-28 09:59:33,150 TRACE [reader] [TransportImpl] Received packet CHANNEL_CLOSE
2015-04-28 09:59:33,150 DEBUG [reader] [SessionChannel] Got close
2015-04-28 09:59:33,151 DEBUG [reader] [SessionChannel] Sending close
2015-04-28 09:59:33,151 TRACE [reader] [Encoder] Encoding packet #6: 61 00 00 00 00
2015-04-28 09:59:33,151 DEBUG [reader] [ConnectionImpl] Forgetting `session` channel (#0)
2015-04-28 09:59:33,152 TRACE [reader] [Decoder] Received packet #11: 63 00 00 00 00
2015-04-28 09:59:33,152 TRACE [reader] [TransportImpl] Received packet CHANNEL_SUCCESS
2015-04-28 09:59:33,152 ERROR [reader] [TransportImpl] Dying because - {}
net.schmizz.sshj.connection.ConnectionException: [PROTOCOL_ERROR] Received CHANNEL_SUCCESS on unknown channel #0
From the logs, the channel is forgotten after CHANNEL_CLOSE
. When the CHANNEL_SUCCESS
messages comes in, SSHj no longer recognizes the channel
Solution
Workaround
As this is a limitation with SSHj, this can be worked around by using a script task instead to open the SSH session. As the script depends on the OS ssh client, this error can be avoided.
Script example:
1
2
3
4
sshpass -p sshPassword ssh -p sshPort username@domainName << EOF
<insert script here>
exit
EOF
Resolution
No documented resolution at the moment as this is a limitation with using SSHj.
Was this helpful?