Hi!
I’m trying to connect a Jenkins agent from an AWS EC2 instance to the controller in a Kubernetes cluster. To route the traffic to the controller I’m using Traefik as a reverse proxy (listening for TCP traffic on port 50000). In the node configuration I’ve configured the agent to make the connection using WebSocket because I’ve seen this is the best way to do it having a reverse proxy.
When I execute the command from the EC2 instance I’m getting the following error:
bash5.1$ java -jar agent.jar -jnlpUrl mylocaljenkins.com/computer/test-agent/jenkins-agent.jnlp -secret 3f0c28ad62f2182446fbe152578ada10669498fb556d17426360154170a95cd8 -workDir "/my/working/dir"
Jul 01, 2022 6:32:51 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /my/working/dir/remoting as a remoting work directory
Jul 01, 2022 6:32:51 AM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /my/working/dir/remoting
Jul 01, 2022 6:32:51 AM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: test-agent
Jul 01, 2022 6:32:51 AM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Jul 01, 2022 6:32:51 AM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 4.10
Jul 01, 2022 6:32:51 AM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /my/working/dir/remoting as a remoting work directory
Jul 01, 2022 6:32:52 AM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: Handshake error.
io.jenkins.remoting.shaded.javax.websocket.DeploymentException: Handshake error.
at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager$3$1.run(ClientManager.java:658)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager$3.run(ClientManager.java:696)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:849)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:493)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:337)
at hudson.remoting.Engine.runWebSocket(Engine.java:657)
at hudson.remoting.Engine.run(Engine.java:496)
Caused by: io.jenkins.remoting.shaded.org.glassfish.tyrus.core.HandshakeException: Response code was not 101: 400.
at io.jenkins.remoting.shaded.org.glassfish.tyrus.client.TyrusClientEngine.processResponse(TyrusClientEngine.java:299)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.ClientFilter.processRead(ClientFilter.java:167)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:111)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:113)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.SslFilter.handleRead(SslFilter.java:383)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.SslFilter.processRead(SslFilter.java:345)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:111)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.Filter.onRead(Filter.java:113)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.TransportFilter$4.completed(TransportFilter.java:294)
at io.jenkins.remoting.shaded.org.glassfish.tyrus.container.jdk.client.TransportFilter$4.completed(TransportFilter.java:278)
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:127)
at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:219)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
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)
It’s returning 400 error code so I assume the request is not well but I cannot wonder what can be wrong. I thought the reverse proxy was not well configured but if I execute:
bash5.1$ curl mylocaljenkins.com:50000
Jenkins-Agent-Protocols: JNLP4-connect, Ping
Jenkins-Version: 2.303.1
Jenkins-Session: 871ec1e2
Client: 100.80.18.133
Server: 100.80.46.190
Remoting-Minimum-Version: 3.14
I do get a correct response with some info about the agents and not the HTML code of the Jenkins webpage so I assume the reverse proxy is well configured.
If you have any kind of info I would be very happy if you share it with me.
Thanks in advance!