2017-08-01 586 views
2

雖然連接到Windows機器作爲奴隸,我得到以下錯誤,我認爲它的一些網絡相關的問題,但需要一些幫助在哪裏開始尋找或什麼是一個爲此可能的解決方案。Jenkins Windows從屬連接終止java.nio.channels.ClosedChannelException

INFO: Terminated 
Aug 01, 2017 10:15:54 PM hudson.remoting.JarCacheSupport$1 run 
WARNING: Failed to resolve a jar 06bcb4519543f5ec83cf9d6da9f6cfbe 
java.io.IOException: Failed to write to C:\Users\Administrator\.jenkins\cache\jars\06\BCB4519543F5EC83CF9D6DA9F6CFBE.jar 
     at hudson.remoting.FileSystemJarCache.retrieve(FileSystemJarCache.java:133) 
     at hudson.remoting.JarCacheSupport$1.run(JarCacheSupport.java:64) 
     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:483) 
     at java.util.concurrent.FutureTask.run(FutureTask.java:274) 
     at hudson.remoting.AtmostOneThreadExecutor$Worker.run(AtmostOneThreadExecutor.java:110) 
     at java.lang.Thread.run(Thread.java:809) 
Caused by: java.io.IOException: Backing channel 'JNLP4-connect connection to dr2r4m1p21/172.20.238.41:9001' is disconnected. 
     at hudson.remoting.RemoteInvocationHandler.channelOrFail(RemoteInvocationHandler.java:192) 
     at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:257) 
     at com.sun.proxy.$Proxy4.writeJarTo(Unknown Source) 
     at hudson.remoting.FileSystemJarCache.retrieve(FileSystemJarCache.java:98) 
     ... 5 more 
Caused by: 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.onRecvClosed(SSLEngineFilterLayer.java:166) 
     at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecvClosed(ProtocolStack.java:832) 
     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(ThreadPoolExecutor.java:1157) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627) 
     at hudson.remoting.Engine$1$1.run(Engine.java:94) 
     ... 1 more 

上面提到的堆棧跟蹤是藥膏(Windows)中的機器和我的詹金斯/法師在RHEL上運行,我能夠看到下面的堆棧跟蹤在那裏。

INFO: Accepted JNLP4-connect connection #113 from /172.20.238.31:60363 
Aug 01, 2017 12:45:55 PM jenkins.slaves.DefaultJnlpSlaveReceiver channelClosed 
WARNING: Computer.threadPoolForRemoting [#42] for Build_Agent 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:311) 
     at hudson.remoting.Channel.close(Channel.java:1295) 
     at hudson.remoting.Channel.close(Channel.java:1263) 
     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(ThreadPoolExecutor.java:1142) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
     at java.lang.Thread.run(Thread.java:745) 
+0

你檢查從罐子上機 –

+0

從罐子成功運行Windows成功運行,當我嘗試在slave機器上運行slave.jar時,我能夠看到slave試圖連接到master,然後停止上面提到的堆棧跟蹤和java.nio.channels.ClosedChannelException – yug

+0

您是否使用了固定端口或隨機JNLP端口詹金斯? –

回答

4
  • 我觀察到了同樣的錯誤我們詹金斯師傅被更新後。這可能是由於Java 7(v80)和最新的Java 8之間的不兼容性造成的。
  • 檢查您的主設備以及您的從設備的java版本正在使用的Java版本。
  • 就我而言,我運行羣的客戶端-2.0-JAR-與-dependencies.jar在Linux主機上,並且它使用Java 7

    Java版本 「1.7.0_80」 Java的(TM)SE運行時環境(建 1.7.0_80-B15)的HotSpot的Java(TM)64位服務器VM(24.80建設-B11,混合模式)

  • 我們詹金斯大師進行了升級,現在運行Java 8

    Java版本 「1.8.0_121」 Java(註冊商標)SE運行時環境(建立 1.8.0_121-B13)的Java的HotSpot(TM)64位服務器VM(建立25.121-B13,混合模式)

  • 當從站上的java更新爲Java 8,連接問題消失。
+0

*請注意,Java 7不再接收公共更新:https://java.com/en/download/faq/java_7.xml –

+0

是的解決了它與JAVA8 ..榮譽.. :) – yug

+0

這個問題的主題是關於**奴隸代理**,但這裏是一些有關** maven ** java要求之間的從屬和主要有用的信息:https://wiki.jenkins.io/display/JENKINS/Maven+Project+Plugin in * * Maven作業和Java版本兼容性**部分。 –

0

我遇到過同樣的問題。我發現,如果你的作業沒有在GUI上運行,那麼windows從機就會切換到「睡眠」模式。

  • 對於windows ...沒有移動鼠標或鍵盤意味着沒有活動。

然後成功解決它。在Windows7的奴隸,這裏是我做過什麼:

  • 控制面板\硬件和聲音\電源選項
  • 顯示其它附加計劃
  • 選擇高性能

  • 控制面板\硬件和聲音\電源選項\編輯計劃設置

  • 關閉顯示屏從不
  • 更改高級電源設置 - >關閉硬盤後10000分鐘

如果該過程結束後確定

4

我正經歷着類似的錯誤在哪裏可以我的奴隸連接被丟棄OP。問題的根源不是由於Jenkins從屬主機和主機之間的Java版本不匹配。

解決方案 如果您在EC2實例上的彈性負載均衡(ELB)背後AWS運行詹金斯,從默認爲60秒鐘增加到了「屬性」部分下的「空閒超時」值。我將新值設置爲600,不再遇到錯誤。

看來,如果構建過程中的單個命令的時間超過60秒且沒有日誌輸出,ELB將因閒置活動而終止會話。

來源:https://issues.jenkins-ci.org/browse/JENKINS-44001?focusedCommentId=312412&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-312412

+0

這正是我的問題所在。謝謝! – fatlog

1

除了錯誤日誌在後,我也得到了在從詹金斯目錄下的錯誤日誌(對我來說是C:\詹金斯\詹金斯-slave.err。日誌):

JNLP文件 http://jenkins.domain.com/computer/my_slave_name/slave-agent.jnlp?encrypt=true 具有無效參數:[############################### ######, my_slave_name,-workDir,c:\ jenkins,-internalDir,remoting,-url, http://jenkins.domain.com/,-headless,-jar-cache, C:\ U SERS \ Administrator.jenkins \緩存\罐子]最有可能是 配置錯誤在主 「-workDir」 不是一個有效的選項

我的解決方案:

1)窗口從級別:關閉服務控制檯在所有用戶的GUI - 這是必須的。從某種原因,微軟正在鎖定安裝/刪除Windows服務

2)窗口從級別:殺死所有的Java詹金斯 - 從進程(如果存在的話)

3)窗口從級別:刪除詹金斯奴隸服務(如果存在)從CMD:sc delete jenkinsslave-c__jenkins /force(對我來說)

4)窗口從等級:請確認您有的Java 8 installe d:我正在使用jdk1.8.0_151卸載所有 Java版本

5)詹金斯主UI級別:更改詹金斯被連接到所述從下從配置的方式 - >啓動方法:的Let Jenkins control this Windows slave as a Windows service(代替Launch agent via Java Web Start

6 )AWS級:增加AWS ELB空閒超時600(從60) - 等@njtman建議

7)詹金斯主UI等級:重新啓動代理在jenkins並等待幾分鐘。

我的環境:

詹金斯:2.89.2,操作系統:Windows 2012 R2,JAVA:jdk1.8.0_151