Agent does not stay connected: java.nio.channels.ClosedChannelException

Today, after I rebooted my agent machine, i went to double click the JNLP agent file as usual, but this time after a brief connection, it then displayed ‘terminated’ It has been working for months without this happening, but now my agent machine can no longer connect to Jenkins. No clue why. The Jenkins admin mentioned the other day, he did upgrade Jenkins… But the connection stopped working for me today after an agent reboot. Once in awhile, the agent connection will flicker from ‘terminated’ to ‘connected’ but in the flash of a hair and it stays in a ‘terminated’ state for the most part.
Any ideas on how to resolve?!?!? Thank you!!!
This is what is displayed in Jenkins when I take a look at the agent node:

Connection was broken

at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer.onReadClosed(
at org.jenkinsci.remoting.protocol.ApplicationLayer.onRecvClosed(
at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(
at org.jenkinsci.remoting.protocol.FilterLayer.onRecvClosed(
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.onRecvClosed(
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.switchToNoSecure(
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processWrite(
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processQueuedWrites(
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doSend(
at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doCloseSend(
at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.doCloseSend(
at org.jenkinsci.remoting.protocol.ApplicationLayer.doCloseWrite(
at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer$ByteBufferCommandTransport.closeWrite(
at hudson.remoting.Channel.close(
at hudson.remoting.Channel.close(
at jenkins.slaves.DefaultJnlpSlaveReceiver.afterChannel(
at org.jenkinsci.remoting.engine.JnlpConnectionState.fireAfterChannel(
at org.jenkinsci.remoting.engine.JnlpProtocol4Handler$Handler.lambda$onChannel$0(
at jenkins.util.ContextResettingExecutorService$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

If you’re starting the agent with Java Web Start, then you are probably seeing a regression that was introduced in remoting 4.11.2. Fixed in remoting 4.12, with the fix first included in Jenkins 2.335 and scheduled for inclusion in Jenkins LTS 2.332.1 March 9, 2022.

See JENKINS-67000 for more details and the techniques that can be used to work around the issue.

Java web start is not available with Java 11. Jenkins recommends Java 11. Consider replacing your use of Java web start with one of the alternatives described in that issue report.

Hi Mark! Thank you for your response. I am not using Java Web Start, but using this:
Launch agent by connecting it to the other controller…

If you start the agent and a small window appears on the Windows desktop looks like the image in this issue, then you’re using Java web start.


The workaround is to start the agent from a batch file on the Windows desktop using the command line that is shown on the Jenkins controller for that agent.

Mark, I appreciate you guiding me in the right direction! Ok, so I grabbed the Run from agent command line text and entered it onto the agent, but now getting this error:

Error: Unable to access jarfile agent.jar

I’m in the directory where the jar file exists: C:\Program Files\jdk1.8.0_301\bin, but after entering the command provided by jenkins, I get Error: Unable to access jarfile agent.jar

You need to download agent.jar (clickable link on that page) to your local computer.

Did that, double-clicked it and nothing happens… hmm…

Think i got it, stay tuned!!!

Mark, Thank you!! It works now! Big life saver!



Always a good idea to describe your solution after you found it, either because later you’ll end up googling and finding this post again, or helping the next person :slight_smile:

1 Like

In Jenkins, on node, after the exception displays, it has another way to start the agent connection listed. It includes a jar file link that can be clicked and downloaded to your agent. Save it to a folder, then CMD into that folder and then copy the command provided where you were provided the agent link and paste it in the CMD directory where the agent file lives. It now connects!