jenkins node ssh-connection fails - jenkins

I try to connect a VM(Windows 10) as a node in jenkins with ssh.
But after some lines occurs the following error:
[10/11/18 11:45:10] [SSH] Starting agent process: cd "C:\jenkins" && java -jar remoting.jar -workDir C:\jenkins
<===[JENKINS REMOTING CAPACITY]===>Okt 11, 2018 11:45:11 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFORMATION: Using C:\jenkins\remoting as a remoting work directory
Both error and output logs will be printed to C:\jenkins\remoting
<===[JENKINS REMOTING CAPACITY]===>ERROR: Connection terminated
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:49)
at hudson.remoting.Command.readFrom(Command.java:140)
at hudson.remoting.Command.readFrom(Command.java:126)
at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:36)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:63)
Caused: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:77)
Slave JVM has not reported exit code. Is it still running?
[10/11/18 11:45:17] Launch failed - cleaning up connection
[10/11/18 11:45:17] [SSH] Connection closed.

As noted on https://issues.jenkins-ci.org/browse/JENKINS-42856 this could be a known issue. Can you see if the below workaround mentioned on the above JENKINS bug helps ?
I have a similar problem with the channel being terminated too early. I was able to circumvent it using the following SSH prefix and postfix commands:
Prefix: powershell -Command "cd C:\jenkins ; java -jar slave.jar" ; exit 0 ; rem '
Postfix: '

Related

Unable to start jenkins slave

When i try to start my jenkins slave, the slave exists with error:
[04/14/17 17:22:06] [SSH] Checking java version of java
[04/14/17 17:22:06] [SSH] java -version returned 1.7.0_121.
[04/14/17 17:22:06] [SSH] Starting sftp client.
[04/14/17 17:22:06] [SSH] Copying latest slave.jar...
[04/14/17 17:22:06] [SSH] Copied 719,269 bytes.
Expanded the channel window size to 4MB
[04/14/17 17:22:06] [SSH] Starting slave process: cd "/home/jenkins" && java -jar slave.jar -text
<===[JENKINS REMOTING CAPACITY]===><===[HUDSON TRANSMISSION BEGINS]===channel started
Slave JVM has not reported exit code. Is it still running?
[04/14/17 17:22:11] Launch failed - cleaning up connection
ERROR: Connection terminated
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2625)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3100)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:854)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:350)
at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:48)
at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:34)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:59)
Caused: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:73)
[04/14/17 17:22:11] [SSH] Connection closed.
Is there anyway to fix this? I've googled, and googled, and googled, but can't find anything to solve this problem.
I haven't faced the same issue, but I guess it may be linked to this:
https://issues.jenkins-ci.org/browse/JENKINS-27624
(It is in case your Jenkins version is 2.54 - minimum java version should be 8)

Can not connect a Jenkins node

An error occurs when I try to set up a Jenkins node. I am using Jenkins ver. 2.46. I am using ssh keys to authenticate the node.
Both master and node are Ubuntu 16.10, running 4.8.0-37-generic kernel and openjdk version "1.8.0_121"
err I get:
[02/18/17 13:09:57] [SSH] Opening SSH connection to 10.171.0.1:22.
[02/18/17 13:09:59] [SSH] Authentication successful.
[02/18/17 13:09:59] [SSH] The remote users environment is:
BASH=/bin/bash
BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="3" [2]="46" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION='4.3.46(1)-release'
DIRSTACK=()
EUID=1004
GROUPS=()
HOME=/var/jenkins
HOSTNAME=wanda
HOSTTYPE=x86_64
IFS=$' \t\n'
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LOGNAME=jenkins
MACHTYPE=x86_64-pc-linux-gnu
MAIL=/var/mail/jenkins
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
PIPESTATUS=([0]="0")
PPID=22036
PS4='+ '
PWD=/var/jenkins
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
SSH_CLIENT='10.144.72.139 33520 22'
SSH_CONNECTION='10.144.72.139 33520 10.171.0.1 22'
TERM=dumb
UID=1004
USER=jenkins
XDG_RUNTIME_DIR=/run/user/1004
XDG_SESSION_ID=116
_=']'
[02/18/17 13:09:59] [SSH] Checking java version of java
[02/18/17 13:10:00] [SSH] java -version returned 1.8.0_121.
[02/18/17 13:10:00] [SSH] Starting sftp client.
[02/18/17 13:10:01] [SSH] Copying latest slave.jar...
[02/18/17 13:10:05] [SSH] Copied 717,563 bytes.
Expanded the channel window size to 4MB
[02/18/17 13:10:05] [SSH] Starting slave process: cd "/var/jenkins" && java -jar slave.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
Slave.jar version: 3.4.1
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
java.util.concurrent.CancellationException
at java.util.concurrent.FutureTask.report(FutureTask.java:121)
at java.util.concurrent.FutureTask.get(FutureTask.java:192)
at hudson.plugins.sshslaves.SSHLauncher.launch(SSHLauncher.java:767)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:262)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
hudson.util.IOException2: Slave start aborted.
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:992)
at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:139)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:738)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:719)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at hudson.remoting.Request.call(Request.java:147)
at hudson.remoting.Channel.call(Channel.java:821)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:520)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:390)
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:989)
... 7 more
ERROR: Connection terminated
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2624)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3099)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
at hudson.remoting.ObjectInputStreamEx.<init>(ObjectInputStreamEx.java:48)
at hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:34)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:59)
Caused: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:73)
Slave JVM has not reported exit code. Is it still running?
[02/18/17 13:10:08] [SSH] Connection closed.
I've entered too small value in advanced settings:
Connection Timeout in Seconds

I am using Jenkins ver. 1.640, and when I try to launch slave then i got this error

I am using ssh key pairs for launching the slaves.Someslaves are working fine. but someslaves when I try to "relaunch slave agent", then i got this error as below. OS :- Ubuntu 14.04LTS ,java version "1.7.0_65" on slave machine and on jenkins server machine java version "1.7.0_85".
Expanded the channel window size to 4MB
[01/22/16 07:41:12] [SSH] Starting slave process: cd "/home/tmp" && java -jar slave.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
Slave.jar version: 2.53.2
This is a Unix slave
Evacuated stdout
Connection terminated
ERROR: Failed to install restarter
hudson.remoting.RequestAbortedException: hudson.remoting.Channel$OrderlyShutdown
at hudson.remoting.Request.abort(Request.java:297)
at hudson.remoting.Channel.terminate(Channel.java:847)
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
at hudson.remoting.Channel$1.handle(Channel.java:501)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)
at ......remote call to Mbox_19(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.Request.call(Request.java:172)
at hudson.remoting.Channel.call(Channel.java:780)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller.install(JnlpSlaveRestarterInstaller.java:52)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller.access$000(JnlpSlaveRestarterInstaller.java:33)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$1.call(JnlpSlaveRestarterInstaller.java:39)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$1.call(JnlpSlaveRestarterInstaller.java:36)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
Caused by: hudson.remoting.Channel$OrderlyShutdown
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
at hudson.remoting.Channel$1.handle(Channel.java:501)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)
Caused by: Command close created at
I hit the same problem and was able to fix it by re-downloading the slave.jar from the Jenkins master. Apparently during an upgrade something about the interface between master and slave had changed. You may want to try 're-installing' your slave configuration by re-downloading and updating your secret.

Getting error when launching Jenkins slave on Ubuntu 14.04 remotely

Error in Jenkins ver. 1.640, Ubuntu 14.04. This problem a lot of times in Jenkins, and can't resolve it. I get the following output
[01/22/16 07:35:31] [SSH] Checking java version of java
[01/22/16 07:35:36] [SSH] java -version returned 1.7.0_65.
[01/22/16 07:35:36] [SSH] Starting sftp client.
[01/22/16 07:35:40] [SSH] Copying latest slave.jar...
[01/22/16 07:41:10] [SSH] Copied 506,256 bytes.
Expanded the channel window size to 4MB
[01/22/16 07:41:12] [SSH] Starting slave process: cd "/home/tmp" && java -jar slave.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
Slave.jar version: 2.53.2
This is a Unix slave
Evacuated stdout
Connection terminated
ERROR: Failed to install restarter
hudson.remoting.RequestAbortedException: hudson.remoting.Channel$OrderlyShutdown
at hudson.remoting.Request.abort(Request.java:297)
at hudson.remoting.Channel.terminate(Channel.java:847)
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
at hudson.remoting.Channel$1.handle(Channel.java:501)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)
at ......remote call to Mbox_19(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.Request.call(Request.java:172)
at hudson.remoting.Channel.call(Channel.java:780)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller.install(JnlpSlaveRestarterInstaller.java:52)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller.access$000(JnlpSlaveRestarterInstaller.java:33)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$1.call(JnlpSlaveRestarterInstaller.java:39)
at jenkins.slaves.restarter.JnlpSlaveRestarterInstaller$1.call(JnlpSlaveRestarterInstaller.java:36)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
Caused by: hudson.remoting.Channel$OrderlyShutdown
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
at hudson.remoting.Channel$1.handle(Channel.java:501)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)
Caused by: Command close created at
at hudson.remoting.Command.<init>(Command.java:56)
at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1074)
at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1072)
at hudson.remoting.Channel.close(Channel.java:1156)
at hudson.remoting.Channel.close(Channel.java:1138)
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1079)
... 2 more
hudson.remoting.RequestAbortedException: hudson.remoting.Channel$OrderlyShutdown
at hudson.remoting.Request.abort(Request.java:297)
at hudson.remoting.Channel.terminate(Channel.java:847)
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
at hudson.remoting.Channel$1.handle(Channel.java:501)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)
at ......remote call to Mbox_19(Native Method)
at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
at hudson.remoting.Request.call(Request.java:172)
at hudson.remoting.Channel.call(Channel.java:780)
at org.jenkinsci.modules.launchd_slave_installer.SlaveInstallerFactoryImpl.createIfApplicable(SlaveInstallerFactoryImpl.java:30)
at org.jenkinsci.modules.slave_installer.SlaveInstallerFactory.createIfApplicable(SlaveInstallerFactory.java:29)
at org.jenkinsci.modules.slave_installer.SlaveInstallerFactory.createFor(SlaveInstallerFactory.java:46)
at org.jenkinsci.modules.slave_installer.impl.ComputerListenerImpl.onOnline(ComputerListenerImpl.java:30)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:573)
at hudson.slaves.SlaveComputer.setChannel(SlaveComputer.java:381)
at hudson.plugins.sshslaves.SSHLauncher.startSlave(SSHLauncher.java:945)
at hudson.plugins.sshslaves.SSHLauncher.access$400(SSHLauncher.java:133)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:711)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: hudson.remoting.Channel$OrderlyShutdown
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1080)
at hudson.remoting.Channel$1.handle(Channel.java:501)
at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:60)
Caused by: Command close created at
at hudson.remoting.Command.<init>(Command.java:56)
at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1074)
at hudson.remoting.Channel$CloseCommand.<init>(Channel.java:1072)
at hudson.remoting.Channel.close(Channel.java:1156)
at hudson.remoting.Channel.close(Channel.java:1138)
at hudson.remoting.Channel$CloseCommand.execute(Channel.java:1079)
... 2 more
[01/22/16 07:48:40] Launch failed - cleaning up connection
[01/22/16 07:48:40] [SSH] Connection closed.
Looks related to an existing Jenkins bug.
It seems this can be resolved by downgrading to kernel 3.4.x. Another possible fix is disabling TCP scatter-gather on the network interface.
Manage Jenkins -> Configure Global Security -> Tick check-box "Enable security",
then see "TCP port for JNLP slave agents" and select Random as option.

jenkins cli command gives error java.io.StreamCorruptedException: invalid stream header: 0A0A0A0A

I am trying to execute jenkins cli command
java -jar /home/jenkins/jenkins-cli.jar -s http://jenkins.server.com/ version --username jenkins --password jenkins
Getting following error
Aug 05, 2015 6:01:02 AM
hudson.remoting.SynchronousCommandTransport$ReaderThread run SEVERE:
I/O error in channel Chunked connection to
http://jenkins.server.com/cli java.io.StreamCorruptedException:
invalid stream header: 0A0A0A0A at
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
at java.io.ObjectInputStream.(ObjectInputStream.java:299) at
hudson.remoting.ObjectInputStreamEx.(ObjectInputStreamEx.java:40)
at
hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:34)
at
hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:48)
hudson.remoting.RequestAbortedException:
java.io.StreamCorruptedException: invalid stream header: 0A0A0A0A at
hudson.remoting.Request.abort(Request.java:296) at
hudson.remoting.Channel.terminate(Channel.java:815) at
hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:69)
at ......remote call to Chunked connection to
http://jenkins.server.com/cli(Native Method) at
hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1361)
at hudson.remoting.Request.call(Request.java:171) at
hudson.remoting.Channel.call(Channel.java:752) at
hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:179)
at hudson.remoting.$Proxy1.waitForProperty(Unknown Source) at
hudson.remoting.Channel.waitForRemoteProperty(Channel.java:1205) at
hudson.cli.CLI.(CLI.java:147) at
hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
at hudson.cli.CLI._main(CLI.java:479) at
hudson.cli.CLI.main(CLI.java:390)
Caused by:
java.io.StreamCorruptedException: invalid stream header: 0A0A0A0A at
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
at java.io.ObjectInputStream.(ObjectInputStream.java:299) at
hudson.remoting.ObjectInputStreamEx.(ObjectInputStreamEx.java:40)
at
hudson.remoting.AbstractSynchronousByteArrayCommandTransport.read(AbstractSynchronousByteArrayCommandTransport.java:34)
at
hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:48)
Go to Configure Global Security > TCP port for JNLP agents and chose Random
save and run your command again
It seems this is a similar problem as:
https://issues.jenkins-ci.org/browse/JENKINS-23232
It suggests that you can add in your Jenkins system config:
JAVA_ARGS="-Dhudson.diyChunking=false"
(in /etc/sysconfig/jenkins for RHEL ; /etc/default/jenkins for Ubuntu/Debian)
You will need to do a restart of the Jenkins server
The only thing that worked for me was:
sudo apt-get install openjdk-7-jre

Resources