Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-29798

Failed to listen to incoming slave connection after fixing port through init.groovy.d

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      When using a init.groovy.d script to set the slave agent port to a fixed value (like the official docker image for Jenkins does), Jenkins shows an error message that seem to tell us that it failed to listen to the agent port.

      java.net.BindException: Failed to listen on port 10000 because it's already in use.
      at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:74)
      at jenkins.model.Jenkins.<init>(Jenkins.java:825)
      at hudson.model.Hudson.<init>(Hudson.java:83)
      at hudson.model.Hudson.<init>(Hudson.java:79)
      at hudson.WebAppMain$3.run(WebAppMain.java:225)
      Caused by: java.net.BindException: Address already in use
      at sun.nio.ch.Net.bind0(Native Method)
      at sun.nio.ch.Net.bind(Net.java:436)
      at sun.nio.ch.Net.bind(Net.java:428)
      at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
      at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
      at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
      at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:72)
      ... 4 more

      As a workaround, people have been adding delays, but really the issue is that we have the following sequence of events occurring :

      • Jenkins init
      • init.groovy.d
        • calls Jenkins.getInstance(). setSlaveAgentPort(xxx)
          • behind the scenes, this call starts the TcpSlaveAgentListener
      • initializes TcpSlaveAgentListener, but doesn't suppose that it may have been started before => the port is already taken, hence the error message above.

          [JENKINS-29798] Failed to listen to incoming slave connection after fixing port through init.groovy.d

          Vincent Latombe created issue -
          Vincent Latombe made changes -
          Description Original: When using a init.groovy.d script to set the slave agent port to a fixed value (like the [official docker image|https://github.com/jenkinsci/docker/blob/master/init.groovy] for Jenkins does), Jenkins shows an error message that seem to tell us that it failed to listen to the agent port.

          {quote}
          java.net.BindException: Failed to listen on port 10000 because it's already in use.
          at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:74)
          at jenkins.model.Jenkins.<init>(Jenkins.java:825)
          at hudson.model.Hudson.<init>(Hudson.java:83)
          at hudson.model.Hudson.<init>(Hudson.java:79)
          at hudson.WebAppMain$3.run(WebAppMain.java:225)
          Caused by: java.net.BindException: Address already in use
          at sun.nio.ch.Net.bind0(Native Method)
          at sun.nio.ch.Net.bind(Net.java:436)
          at sun.nio.ch.Net.bind(Net.java:428)
          at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
          at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
          at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
          at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:72)
          ... 4 more
          {quote}

          As a workaround, people have been adding delays, but really the issue is that we have the following sequence of events occurring :
          - Jenkins init
          - init.groovy.d
            - calls Jenkins.getInstance(). setSlaveAgentPort(xxx)
              - behind the scenes, this call starts the TcpSlaveAgentListener
          - initializes TcpSlaveAgentListener, but doesn't suppose that it may have been started before => the port is already taken, hence the error message above.
          New: When using a init.groovy.d script to set the slave agent port to a fixed value (like the [official docker image|https://github.com/jenkinsci/docker/blob/master/init.groovy] for Jenkins does), Jenkins shows an error message that seem to tell us that it failed to listen to the agent port.

          {quote}
          java.net.BindException: Failed to listen on port 10000 because it's already in use.
          at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:74)
          at jenkins.model.Jenkins.<init>(Jenkins.java:825)
          at hudson.model.Hudson.<init>(Hudson.java:83)
          at hudson.model.Hudson.<init>(Hudson.java:79)
          at hudson.WebAppMain$3.run(WebAppMain.java:225)
          Caused by: java.net.BindException: Address already in use
          at sun.nio.ch.Net.bind0(Native Method)
          at sun.nio.ch.Net.bind(Net.java:436)
          at sun.nio.ch.Net.bind(Net.java:428)
          at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
          at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
          at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:67)
          at hudson.TcpSlaveAgentListener.<init>(TcpSlaveAgentListener.java:72)
          ... 4 more
          {quote}

          As a workaround, people have been adding delays, but really the issue is that we have the following sequence of events occurring :
          - Jenkins init
          - init.groovy.d
          -* calls Jenkins.getInstance(). setSlaveAgentPort(xxx)
          -** behind the scenes, this call starts the TcpSlaveAgentListener
          - initializes TcpSlaveAgentListener, but doesn't suppose that it may have been started before => the port is already taken, hence the error message above.
          Vincent Latombe made changes -
          Assignee New: Vincent Latombe [ vlatombe ]
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 164874 ] New: JNJira + In-Review [ 197568 ]
          ovi craciun made changes -
          Resolution Original: Fixed [ 1 ]
          Status Original: Resolved [ 5 ] New: Reopened [ 4 ]

            vlatombe Vincent Latombe
            vlatombe Vincent Latombe
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: