2
votes

So I am trying to connect my jnlp slave agent (via java web start) to my master jenkins machine.

I have port 49187 fixed for tcp connection of jnlp slave agents and its open in slave machines. As I try and connect, it goes past the handshake but then fails with the following error:

Aug 19, 2014 3:51:10 PM com.youdevise.hudson.slavestatus.SlaveListener call
INFO: Slave-status listener starting
Aug 19, 2014 3:51:10 PM com.youdevise.hudson.slavestatus.SlaveListener$1 run
SEVERE: Could not listen on port
java.net.BindException: Address already in use: JVM_Bind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(Unknown Source)
        at java.net.ServerSocket.bind(Unknown Source)
        at java.net.ServerSocket.<init>(Unknown Source)
        at java.net.ServerSocket.<init>(Unknown Source)
        at com.youdevise.hudson.slavestatus.SocketHTTPListener.waitForConnection
(SlaveListener.java:129)
        at com.youdevise.hudson.slavestatus.SlaveListener$1.run(SlaveListener.ja
va:63)
        at com.youdevise.hudson.slavestatus.Daemon.go(Daemon.java:16)
        at com.youdevise.hudson.slavestatus.SlaveListener.call(SlaveListener.jav
a:83)
        at hudson.remoting.UserRequest.perform(UserRequest.java:118)
        at hudson.remoting.UserRequest.perform(UserRequest.java:48)
        at hudson.remoting.Request$2.run(Request.java:326)
        at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecut
orService.java:72)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at hudson.remoting.Engine$1$1.run(Engine.java:58)
        at java.lang.Thread.run(Unknown Source)

I have inbound , outbound opne but no idea why I am facing this error..Any ideas?

Heres the output for suggested answer:

[root@ip-10-192-35-89 ~]# netstat -ntpl | grep 49187
tcp        0      0 :::49187                    :::*                        LISTEN      1054/java
[root@ip-10-192-35-89 ~]# ps -ef|grep 1054
jenkins   1054     1  2 Aug14 ?        02:56:02 /etc/alternatives/java -Djava.awt.headless=true -Xmx2048m -XX:MaxPermSize=512m -DJENKINS_HOME=/var/lib/jenkins -jar /usr/lib/jenkins/jenkins.war --logfile=/var/log/jenkins/jenkins.log --webroot=/var/cache/jenkins/war --httpPort=7777 --ajp13Port=8009 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
root      2483  2463  0 19:18 pts/0    00:00:00 grep 1054
2
@Did you try the suggestion? - Technext
@Technext - yes and it worked! - Scooby
I'm glad it worked. :) - Technext
What Suggestion are you talking here ? - SteveScm

2 Answers

3
votes

From the following lines, it seems some process is already using the port 49187:

SEVERE: Could not listen on port
java.net.BindException: Address already in use: JVM_Bind

Just run the following command to fetch the process id:

netstat -ntpl | grep 49187

From the output, fetch the process-id and then run the following command to see which process is using the port 49187. You can then kill that process and try connecting to JNLP slave agent.

ps -ef | grep PID_from_above_output

For example,

[root@jenkins gc]# netstat -ntpl | grep 1569
tcp        0      0 127.0.0.1:25       0.0.0.0:*    LISTEN      1569/sendmail
[root@jenkins gc]#
[root@jenkins gc]# ps -ef | grep 1569
root      1569     1  0 Jun26 ?        00:01:13 sendmail: accepting connections
root      8083  8059  0 21:35 pts/0    00:00:00 grep 1569

As you can see, sendmail program was using port 1569 to listen to requests.

0
votes

When i got into the issues where it says that JNLP Port is already in use. I tried grepping and doing a netstat on jenkins master for our JNLP port, i never got any process running on that particular port. Seems jenkins is storing the JNLP port information somewhere and not sure of it. What i did was to change the JNLP port to some other port, saved the configuration, tried running the slave command, then updated the JNLP port with the same old one again and restarted the jnlp slave again. It works with out any issues now. Apparently the problem occurred when we restarted our jenkins master.