title: Jenkins windows slave lose connection continuously with error: ClosedChannelException
body: <p>Jenkins 2.107.2</p>
  
  <p>Master: Windows Server 2008R2, java version "1.8.0_171" 
  Slave: Windows Server 2016, java version "1.8.0_161" on master</p>
  
  <p>I already tried:</p>
  
  <ol>
  <li>turn off firewall</li>
  <li>change 'Power Options': Turn off the display: Never</li>
  <li>Jenkins: TCP port for JNLP agents: tried both fixed and Random, with Agent protocols, only <code>Java Web Start Agent Protocol/4 (TLS encryption)</code> selected.</li>
  </ol>
  
  <p>Any other things I can try or troubleshoot?</p>
  
  <p>Thank you so much for your help!</p>
  
  <p>Error on the slave node page on the master Jenkins:</p>
  
  <pre><code>Connection was broken
  
  java.nio.channels.ClosedChannelException
      at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer.onReadClosed(ChannelApplicationLayer.java:208)
      at org.jenkinsci.remoting.protocol.ApplicationLayer.onRecvClosed(ApplicationLayer.java:222)
      at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(ProtocolStack.java:832)
      at org.jenkinsci.remoting.protocol.FilterLayer.onRecvClosed(FilterLayer.java:287)
      at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.onRecvClosed(SSLEngineFilterLayer.java:181)
      at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.switchToNoSecure(SSLEngineFilterLayer.java:283)
      at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processWrite(SSLEngineFilterLayer.java:503)
      at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processQueuedWrites(SSLEngineFilterLayer.java:248)
      at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doSend(SSLEngineFilterLayer.java:200)
      at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doCloseSend(SSLEngineFilterLayer.java:213)
      at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.doCloseSend(ProtocolStack.java:800)
      at org.jenkinsci.remoting.protocol.ApplicationLayer.doCloseWrite(ApplicationLayer.java:173)
      at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer$ByteBufferCommandTransport.closeWrite(ChannelApplicationLayer.java:313)
      at hudson.remoting.Channel.close(Channel.java:1446)
      at hudson.remoting.Channel.close(Channel.java:1399)
      at jenkins.slaves.DefaultJnlpSlaveReceiver.afterChannel(DefaultJnlpSlaveReceiver.java:173)
      at org.jenkinsci.remoting.engine.JnlpConnectionState$4.invoke(JnlpConnectionState.java:421)
      at org.jenkinsci.remoting.engine.JnlpConnectionState.fire(JnlpConnectionState.java:312)
      at org.jenkinsci.remoting.engine.JnlpConnectionState.fireAfterChannel(JnlpConnectionState.java:418)
      at org.jenkinsci.remoting.engine.JnlpProtocol4Handler$Handler$1.run(JnlpProtocol4Handler.java:334)
      at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>slave log:</p>
  
  <pre><code>May 03, 2018 5:46:35 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
  INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
  May 03, 2018 5:47:12 PM hudson.remoting.JarCacheSupport$DownloadRunnable run
  WARNING: Failed to resolve a jar c7fd87b9bf7e59d00b1b183cf4aecbfc
  java.io.IOException: Failed to write to C:\Users\fazzt\Documents\jenkins\remoting\jarCache\C7\FD87B9BF7E59D00B1B183CF4AECBFC.jar
      at hudson.remoting.FileSystemJarCache.retrieve(FileSystemJarCache.java:150)
      at hudson.remoting.JarCacheSupport$DownloadRunnable.run(JarCacheSupport.java:110)
      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:112)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.io.IOException: Backing channel 'JNLP4-connect connection to QASYSTEM/10.7.208.204:49363' is disconnected.
      at hudson.remoting.RemoteInvocationHandler.channelOrFail(RemoteInvocationHandler.java:209)
      at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:278)
      at com.sun.proxy.$Proxy3.writeJarTo(Unknown Source)
      at hudson.remoting.FileSystemJarCache.retrieve(FileSystemJarCache.java:115)
      ... 5 more
  Caused by: java.nio.channels.ClosedChannelException
      at org.jenkinsci.remoting.protocol.NetworkLayer.onRecvClosed(NetworkLayer.java:154)
      at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer.access$1500(BIONetworkLayer.java:48)
      at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader.run(BIONetworkLayer.java:247)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at hudson.remoting.Engine$1$1.run(Engine.java:94)
      ... 1 more
  </code></pre>
  
  <p>master log:</p>
  
  <pre><code>WARNING: Making SlaveNode1 offline because it’s not responding
  May 07, 2018 5:59:21 AM jenkins.slaves.DefaultJnlpSlaveReceiver channelClosed
  WARNING: Computer.threadPoolForRemoting [#1201] for SlaveNode1 terminated
  java.nio.channels.ClosedChannelException
  at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer.onReadClosed(ChannelApplicationLayer.java:208)
  at org.jenkinsci.remoting.protocol.ApplicationLayer.onRecvClosed(ApplicationLayer.java:222)
  at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(ProtocolStack.java:832)
  at org.jenkinsci.remoting.protocol.FilterLayer.onRecvClosed(FilterLayer.java:287)
  at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.onRecvClosed(SSLEngineFilterLayer.java:181)
  at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.switchToNoSecure(SSLEngineFilterLayer.java:283)
  at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processWrite(SSLEngineFilterLayer.java:503)
  at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.processQueuedWrites(SSLEngineFilterLayer.java:248)
  at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doSend(SSLEngineFilterLayer.java:200)
  at org.jenkinsci.remoting.protocol.impl.SSLEngineFilterLayer.doCloseSend(SSLEngineFilterLayer.java:213)
  at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.doCloseSend(ProtocolStack.java:800)
  at org.jenkinsci.remoting.protocol.ApplicationLayer.doCloseWrite(ApplicationLayer.java:173)
  at org.jenkinsci.remoting.protocol.impl.ChannelApplicationLayer$ByteBufferCommandTransport.closeWrite(ChannelApplicationLayer.java:313)
  at hudson.remoting.Channel.close(Channel.java:1446)
  at hudson.remoting.Channel.close(Channel.java:1399)
  at jenkins.slaves.DefaultJnlpSlaveReceiver.afterChannel(DefaultJnlpSlaveReceiver.java:173)
  at org.jenkinsci.remoting.engine.JnlpConnectionState$4.invoke(JnlpConnectionState.java:421)
  at org.jenkinsci.remoting.engine.JnlpConnectionState.fire(JnlpConnectionState.java:312)
  at org.jenkinsci.remoting.engine.JnlpConnectionState.fireAfterChannel(JnlpConnectionState.java:418)
  at org.jenkinsci.remoting.engine.JnlpProtocol4Handler$Handler$1.run(JnlpProtocol4Handler.java:334)
  at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  at java.lang.Thread.run(Unknown Source)
  </code></pre>