Unable to start inbound agent on windows server

I am using a docker image from Docker Hub to launch inbound agent on my windows ec2 instance.I am able to connect using the agent.jar method so no connection issues there, but when I try to run the inbound agent docker container I am unable to pass the Websocket parameter or as environment variable (JENKINS_WEB_SOCKET).

This is how I am launching the container,

docker run jenkins/inbound-agent:windowsservercore-1809 -Url https://myjenkins.com -Secret d******c -Name aws-jenkins-windows-inbound-agent -WebSocket true

But the container does not recognize it and failing with this error.

true : The term 'true' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:1

how are you passing it?
I don’t have a windows machine to test with, but i’m guessing -WebSocket is a boolean flag (true if there, false if not), so you don’t need to provide true, thus its trying to run “true” which isn’t a command in windows

I did pass without the true just -WebSocket, but it does not like that either, for instance,

docker run jenkins/inbound-agent:windowsservercore-1809 -Url https://myjenkins.com -Secret d**********c -Name aws-jenkins-windows-inbound-2  -WorkDir 'C:\Jenkins2' -WebSocket
Apr 26, 2022 7:52:35 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: aws-jenkins-windows-inbound
Apr 26, 2022 7:52:35 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Apr 26, 2022 7:52:35 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 4.3
Apr 26, 2022 7:52:35 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using C:\Jenkins2\remoting as a remoting work directory
Apr 26, 2022 7:52:35 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to C:\Jenkins2\remoting
Apr 26, 2022 7:52:35 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: Connection failed.
io.jenkins.remoting.shaded.javax.websocket.DeploymentException: Connection failed.
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.JdkClientContainer$1.call(JdkClientContainer.java:200)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.JdkClientContainer$1.call(JdkClientContainer.java:126)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.JdkClientContainer.openClientSocket(JdkClientContainer.java:205)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:663)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:712)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:866)
        at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:511)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:355)
        at hudson.remoting.Engine.runWebSocket(Engine.java:627)
        at hudson.remoting.Engine.run(Engine.java:469)
Caused by: java.nio.channels.UnresolvedAddressException
        at sun.nio.ch.Net.checkAddress(Net.java:104)
        at sun.nio.ch.WindowsAsynchronousSocketChannelImpl.implConnect(WindowsAsynchronousSocketChannelImpl.java:332)
        at sun.nio.ch.AsynchronousSocketChannelImpl.connect(AsynchronousSocketChannelImpl.java:210)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.TransportFilter.handleConnect(TransportFilter.java:192)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.connect(Filter.java:103)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.connect(Filter.java:106)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.connect(Filter.java:106)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.ClientFilter.connect(ClientFilter.java:122)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.JdkClientContainer.connectSynchronously(JdkClientContainer.java:337)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.JdkClientContainer.access$700(JdkClientContainer.java:80)
        at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.JdkClientContainer$1.call(JdkClientContainer.java:169)
        ... 12 more

This means that your agent in the container cannot resolve myjenkins.com. Make sure to check your Jenkins master is reachable from the agent.

Most probably the environment variable is passed over correctly.

Hi Marcin,

I can confirm that the agent can resolve the jenkins server because I am able to connect it using the agent.jar method. But it is the container which does not like the -WebSocket parameter. I tried the same thing in linux machine and I was able to connect the agent container to jenkins. And I am passing the same parameter they suggested on the wiki, but it is not working.

Can you give the invocation that works without -WebSocket?