3

I've set-up a Jenkins on AWS ec2 instance. I have a few machines with me (Ubuntu, Mac) which are supposed to be the slaves.

I've configured the nodes on my Jenkins master and I'm trying to connect the slaves using JNLP-4 protocol via random ports.

I've enabled the Security, Selected the TCP Ports for agents as Random, Enable CLI over remoting, Enable Agent -> Master Access control.

After doing all these, when I try to connect I get the following error:

Vighneshs-MBP:Downloads vighneshpai$ java -jar agent.jar -jnlpUrl https://my.host.name/computer/Mac/slave-agent.jnlp -secret cf400d1a4e0a1dcc75da2b361efafbce3321e17b935bdcf14350a36e
Oct 11, 2018 8:43:50 PM hudson.remoting.jnlp.Main createEngine
INFO: Setting up agent: Mac
Oct 11, 2018 8:43:50 PM hudson.remoting.jnlp.Main$CuiListener <init>
INFO: Jenkins agent is running in headless mode.
Oct 11, 2018 8:43:50 PM hudson.remoting.Engine startEngine
INFO: Using Remoting version: 3.25
Oct 11, 2018 8:43:50 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /Users/vighneshpai/Downloads/remoting as a remoting work directory
Both error and output logs will be printed to /Users/vighneshpai/Downloads/remoting
Oct 11, 2018 8:43:50 PM hudson.remoting.jnlp.Main$CuiListener status
INFO: Locating server among [https://my.host.name/]
Oct 11, 2018 8:43:51 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver resolve
INFO: Remoting server accepts the following protocols: [JNLP4-connect, JNLP-connect, Ping, JNLP2-connect, JNLP3-connect]
Oct 11, 2018 8:43:56 PM org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver isPortVisible
WARNING: connect timed out
Oct 11, 2018 8:43:56 PM hudson.remoting.jnlp.Main$CuiListener error
SEVERE: https://my.host.name/ provided port:49187 is not reachable
java.io.IOException: https://my.host.name/ provided port:49187 is not reachable
    at org.jenkinsci.remoting.engine.JnlpAgentEndpointResolver.resolve(JnlpAgentEndpointResolver.java:286)
    at hudson.remoting.Engine.innerRun(Engine.java:523)
    at hudson.remoting.Engine.run(Engine.java:474)

I've also tried using a Fixed port and add the port to the allowed list of ports for Inbound access. Still not able to connect.

Same machines, without any problem connected to the Jenkins running on local machine.

What could be the problem?

Vighnesh Pai
  • 1,795
  • 1
  • 14
  • 38
  • Please give more information on your setup. Your Jenkins slaves are also on AWS or they are local machines? First of all you need to make sure that networking is configured properly. Use tools like ‘nc’ to verify this. SSH to Jenkins master and do ‘nc ’. And see it it is able to reach slave at all. – gp42 Oct 11 '18 at 16:21
  • Yeah, my machines are local ones. Regarding the networking, they are configured properly. I've checked with two different networks. One with firewall and one without firewall. – Vighnesh Pai Oct 11 '18 at 16:23
  • Try to run this netcat command and tell the result. Normally remote host should drop the connection after some time. If its not the case and the connection just ‘hangs’, then networking is not right. – gp42 Oct 11 '18 at 16:25
  • I figured out that, all my network connections are working as required. – Vighnesh Pai Oct 11 '18 at 17:45
  • 1
    There's also an info about configuring the ports behind some security sensitive network which can prevent me from making this connection. https://stackoverflow.com/questions/38729686/jenkins-how-to-configure-jenkins-behind-nginx-reverse-proxy-for-jnlp-slaves-to/39965700#39965700 – Vighnesh Pai Oct 11 '18 at 17:47
  • I did configure the port 49187 in my load balancer and now, i'm able to see that there is a java process which is holding onto 49187 port. – Vighnesh Pai Oct 11 '18 at 17:48
  • You did not mention load balancer before. I assume this is an elb in front of Jenkins Master? Is this an Application load balancer from AWS or raw TCP? – gp42 Oct 11 '18 at 18:49
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181731/discussion-between-vighnesh-pai-and-gp42). – Vighnesh Pai Oct 12 '18 at 07:22

6 Answers6

4

Setting the property -Dhudson.TcpSlaveAgentListener.hostName in /etc/default/jenkins resolved my problem.

Vighnesh Pai
  • 1,795
  • 1
  • 14
  • 38
2

Changing the port to Fixed instead of random and allowing that particular port in the aws as an exception with TCP, resolved this.

Emjey
  • 2,038
  • 3
  • 18
  • 33
1

If you've setup http_proxy/https_proxy in the environment variables (and it's a proxy which jenkins doesn't like)) then that too will throw this cryptic error.

Mugen
  • 1,417
  • 5
  • 22
  • 40
0

Since your Jenkins AWS instance is behind a firewall your slaves won't be able to connect using your given port (49187) if the port itself is not open. Simply;

  • Add a security group on AWS console, allowing connections on the port (49187 in this case) for your slave IP address(es).

p.s: If it were to be a random Jenkins machine, a simple sudo ufw allow 49187 should suffice:)

Mekky_Mayata
  • 197
  • 2
  • 11
0

If not a firewall issue, make sure that the setting "Dhudson.TcpSlaveAgentListener.hostName" is set when running the Jenkins to the FQDN of the Jenkins master, or a partial record that the agent can reach for sure. In our case this wasn't configured as the FQDN and the slave could not reach the record.

0

My issue was resolved after I performed a Jenkins server restart using the URL https://JenkinsURL/restart Or https://JenkinsURL/SafeRestart

Nikhil
  • 43
  • 7