Windows – Jenkins windows slave unable to connect

javaJenkinsmaster-slavewindows

Trying to start Jenkins slave on Windows with Java Web start gives me this:

>java -jar agent.jar -jnlpUrl https://jenkins.example.com/computer/slave-office/slave-agent.jnlp -secret 74aebde5a38c4f19b0b6c64ee9d3d75571d6cd666e67ebae7d39d8b259d39a0f -workDir C:\Jenkins\
ш■э 26, 2018 5:15:49 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using C:\Jenkins\remoting as a remoting work directory
Both error and output logs will be printed to C:\Jenkins\remoting
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: slave-office
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
ш■э 26, 2018 5:15:50 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3.22
ш■э 26, 2018 5:15:50 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using C:\Jenkins\remoting as a remoting work directory
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [https://jenkins.example.com/]
ш■э 26, 2018 5:15:50 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, Ping]
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Agent discovery successful
  Agent address: jenkins.example.com
  Agent port:    50000
  Identity:      62:e9:82:de:8b:ae:cf:6d:ea:9e:0b:cf:5c:ad:bb:10
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Handshaking
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to jenkins.example.com:50000
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Trying protocol: JNLP4-connect
ш■э 26, 2018 5:15:50 PM org.jenkinsci.remoting.protocol.impl.AckFilterLayer abort
WARNING: [JNLP4-connect connection to jenkins.example.com/11.22.33.44:50000] Incorrect acknowledgement sequence, expected 0x000341434b got 0x485454502f
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Protocol JNLP4-connect encountered an unexpected exception
java.util.concurrent.ExecutionException: org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException: Connection closed before acknowledgement sent
        at org.jenkinsci.remoting.util.SettableFuture.get(SettableFuture.java:223)
        at hudson.remoting.Engine.innerRun(Engine.java:609)
        at hudson.remoting.Engine.run(Engine.java:469)
Caused by: org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException: Connection closed before acknowledgement sent
        at org.jenkinsci.remoting.protocol.impl.AckFilterLayer.onRecvClosed(AckFilterLayer.java:280)
        at org.jenkinsci.remoting.protocol.FilterLayer.abort(FilterLayer.java:164)
        at org.jenkinsci.remoting.protocol.impl.AckFilterLayer.abort(AckFilterLayer.java:130)
        at org.jenkinsci.remoting.protocol.impl.AckFilterLayer.onRecv(AckFilterLayer.java:258)
        at org.jenkinsci.remoting.protocol.ProtocolStack$Ptr.onRecv(ProtocolStack.java:669)
        at org.jenkinsci.remoting.protocol.NetworkLayer.onRead(NetworkLayer.java:136)
        at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer.access$2200(BIONetworkLayer.java:48)
        at org.jenkinsci.remoting.protocol.impl.BIONetworkLayer$Reader.run(BIONetworkLayer.java:283)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at hudson.remoting.Engine$1.lambda$newThread$0(Engine.java:93)
        at java.lang.Thread.run(Unknown Source)

ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Connecting to jenkins.example.com:50000
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Server reports protocol JNLP4-plaintext not supported, skipping
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Server reports protocol JNLP3-connect not supported, skipping
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Server reports protocol JNLP2-connect not supported, skipping
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Server reports protocol JNLP-connect not supported, skipping
ш■э 26, 2018 5:15:50 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: The server rejected the connection: None of the protocols were accepted
java.lang.Exception: The server rejected the connection: None of the protocols were accepted
        at hudson.remoting.Engine.onConnectionRejected(Engine.java:670)
        at hudson.remoting.Engine.innerRun(Engine.java:634)
        at hudson.remoting.Engine.run(Engine.java:469)

TCP port for JNLP agents seems to be correctly configured for 50000

Java Web Start Agent Protocol/4 (TLS encryption) is enabled

Https certificate is correct & curl confirms that the server is available

curl https://jenkins.example.com:50000
Jenkins-Agent-Protocols: JNLP4-connect, Ping
Jenkins-Version: 2.129
Jenkins-Session: 9ab0885c
Client: 10.42.24.96
Server: 10.42.7.42
Remoting-Minimum-Version: 3.4

Best Answer

I encountered the same problem. In my case, connecting directly to the host over a private network worked fine, but connecting through a load balancer resulted in the same exception.

I ran Wireshark and determined that our load balancer was not letting some of the TCP traffic through. I was able to disable HTTP-specific configuration on the load balancer and set it up as a raw TCP pass-through. This was all I needed to fix the connection issues.