# Windows Jenkins agents are disconnecting and tunneling port stopped accepting requests

**URL:** <https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393>\
**Category:** Using Jenkins\
**Tags:** question, docker, windows\
**Created:** [May 15, 2023, 5:56pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393 "2023-05-15T17:56:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ahmed](https://community.jenkins.io/u/Ahmed)\
**Post date:** [May 15, 2023, 5:56pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/1 "2023-05-15T17:56:10Z")

</div>

Hi, I’m using Jenkins which  
Jenkins version is JENKINS\_VERSION 2.375.2  
Java version is java.class.version 55.0  
https.protocols TLSv1.2  
The master node is deployed on an ubuntu server (4.15.0-142-generic #146~16.04.1-Ubuntu)  
And connected to agents through tunneling on port 50000, agents are windows and connected to the master using the jnlp command.  
Now, all of a sudden some agents disconnect for the master and when trying to reconnect gives me this error.

```auto
May 14, 2023 12:33:47 PM hudson.remoting.jnlp.Main$CuiListener status INFO: Connecting to <jenkins>:50000 (retrying:7)
java.io.IOException: Failed to connect to <jenkins>:50000 
at org.jenkinsci.remoting.engine.JnlpAgentEndpoint.open(JnlpAgentEndpoint.java:248) at hudson.remoting.Engine.connectTcp(Engine.java:900) 
at hudson.remoting.Engine.innerRun(Engine.java:784) 
at hudson.remoting.Engine.run(Engine.java:543)
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/sun.nio.ch.Net.connect0(Native Method) 
at java.base/sun.nio.ch.Net.connect(Net.java:483) 
at java.base/sun.nio.ch.Net.connect(Net.java:472)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:692) 
at java.base/java.nio.channels.SocketChannel.open(SocketChannel.java:194)
at org.jenkinsci.remoting.engine.JnlpAgentEndpoint.open(JnlpAgentEndpoint.java:206) 
... 3 more                                                                                                                          

```

The master logs are

```auto
May 12, 2023 11:34:33 PM INFO jenkins.slaves.DefaultJnlpSlaveReceiver channelClosed
IOHub#1: Worker[channel:java.nio.channels.SocketChannel[connected local=/<ip>:50000 remote=<served>]] / Computer.threadPoolForRemoting [#903] for vsb-5 terminated: java.nio.channels.ClosedChannelException
May 12, 2023 11:41:15 PM INFO jenkins.slaves.DefaultJnlpSlaveReceiver channelClosed
IOHub#1: Worker[channel:java.nio.channels.SocketChannel[connected local=/<ip>:50000 remote=<server>]] / Computer.threadPoolForRemoting [#908] for vsb-4 terminated: java.nio.channels.ClosedChannelException
May 12, 2023 11:43:11 PM INFO hudson.slaves.ChannelPinger$1 onDead
Ping failed. Terminating the channel vsb-3.
java.util.concurrent.TimeoutException: Ping started at 1683927551978 hasn't completed by 1683927791979
	at hudson.remoting.PingThread.ping(PingThread.java:132)
	at hudson.remoting.PingThread.run(PingThread.java:88)

```

The UI node logs after disconnecting are

```auto
Connection was broken

java.nio.channels.ClosedChannelException
	at org.jenkinsci.remoting.protocol.NetworkLayer.onRecvClosed(NetworkLayer.java:155)
	at org.jenkinsci.remoting.protocol.impl.NIONetworkLayer.ready(NIONetworkLayer.java:180)
	at org.jenkinsci.remoting.protocol.IOHub$OnReady.run(IOHub.java:789)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:30)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:70)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

```

I checked everything related to the network, and I found that the port is listening on the host but is not listening inside the container.  
The server metrics (CPU, RAM) are also good.

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [May 15, 2023, 6:09pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/2 "2023-05-15T18:09:06Z")

</div>

Just to clarify, you had this working before an update? If so, what version of Jenkins were you using previously that worked? Have you verified that the container 50000 is being redirected internally to the correct port in the container? Does Jenkins have port 50000 setup as the port to accept agent connections. Can you share your agent command line (with secrets redacted)?

---

<div class="post-metadata">

**Author:** ![Ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ahmed](https://community.jenkins.io/u/Ahmed)\
**Post date:** [May 15, 2023, 7:24pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/3 "2023-05-15T19:24:21Z")

</div>

docker-compose ports section:

```auto
 ports:
      - "8080:8080"
      - "50000:50000"

```

Agent command:

```auto
java.exe -jar pathToJar\agent.jar -jnlpUrl <server_ip>/computer/<my-agent>/slave-agent.jnlp -secret <secret> -workDir <workDir>

```

Note:  
I haven’t updated Jenkins yet, everything was fine until two weeks ago, What is weird to me is that some other agents are still connected to the master and working, but all of a sudden some agents disconnect.  
A master restart makes all agents work but after some time a random couple of them are disconnected, and they can’t reconnect.

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [May 15, 2023, 7:49pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/4 "2023-05-15T19:49:01Z")

</div>

Is the agent.jar file the latest from the controller (no longer called master)? Can you try downloading the latest from your controller and try that? Is there anything that changed 2 weeks ago?

---

<div class="post-metadata">

**Author:** ![Ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ahmed](https://community.jenkins.io/u/Ahmed)\
**Post date:** [May 16, 2023, 5:15am UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/5 "2023-05-16T05:15:14Z")

</div>

Yes, It’s the latest version and the dashboard is not showing any warnings related to agent.jar version  
.  
Nothing changed, absolutely nothing.

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [May 16, 2023, 2:43pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/6 "2023-05-16T14:43:57Z")

</div>

You are using JDK 11 or 17 to run the controller and agents?

---

<div class="post-metadata">

**Author:** ![Ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Ahmed](https://community.jenkins.io/u/Ahmed)\
**Post date:** [May 16, 2023, 3:02pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/7 "2023-05-16T15:02:31Z")

</div>

I’m using JDK 11 for both of them.

---

<div class="post-metadata">

**Author:** ![slide\_o\_mix](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/slide_o_mix/32/20977_2.png) [@slide\_o\_mix](https://community.jenkins.io/u/slide_o_mix)\
**Post date:** [May 16, 2023, 4:38pm UTC](https://community.jenkins.io/t/windows-jenkins-agents-are-disconnecting-and-tunneling-port-stopped-accepting-requests/7393/8 "2023-05-16T16:38:19Z")

</div>

I don’t know what else to look at, sorry. We’ll have to see if someone else can help.
