jenkinsci / jenkinsci/port-allocator-plugin
[JENKINS-16057] Problems with dual-stack IPv4 / IPv6 machines
Nobody has claimed this yet.
- 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
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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