jenkinsci / jenkinsci/port-allocator-plugin

[JENKINS-16057] Problems with dual-stack IPv4 / IPv6 machines

Open
#81 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component:port-allocator-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
11
Forks
34
Avg merge
23h 26m
Merged PRs (30d)
1

Description

The plugin was checking whether a named port was free on the build machine, but even when the port was already in use by some daemon, the plugin wrongly reported that the port was available.

The reason appeared to be that our daemon was listening on an IPv4 socket, but the ServerSocket created on the same port by Jenkins defaulted to IPv6, which apparently succeeded.

Switching Jenkins to IPv4 (via java.net.preferIPv4Stack=true) solved the problem.

But it would be nice if Jenkins could handle this situation automatically.

Maybe something like this? I need to investigate when I get time:

```
server = new ServerSocket();
server.bind(new InetSocketAddress(InetAddress.getByName("::"), port));

```

---
Originally reported by orrc, imported from: Problems with dual-stack IPv4 / IPv6 machines


  • status: Open
  • priority: Minor
  • component(s): port-allocator-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 20251216-225446

Raw content of original issue

The plugin was checking whether a named port was free on the build machine, but even when the port was already in use by some daemon, the plugin wrongly reported that the port was available.

The reason appeared to be that our daemon was listening on an IPv4 socket, but the ServerSocket created on the same port by Jenkins defaulted to IPv6, which apparently succeeded.

Switching Jenkins to IPv4 (via java.net.preferIPv4Stack=true) solved the problem.

But it would be nice if Jenkins could handle this situation automatically.

Maybe something like this? I need to investigate when I get time:



server = new ServerSocket();

server.bind(new InetSocketAddress(InetAddress.getByName("::"), port));

  • environment: Mac OS X 10.8.2 master, no slaves

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the port-allocator-plugin path that checks whether a named port is available, and reproduce the case where an IPv4 listener is missed by a Jenkins ServerSocket using IPv6. Compare the socket binding behavior with the suggested dual-stack approach; done means an already-used port is rejected on dual-stack machines without requiring java.net.preferIPv4Stack=true.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.