Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Port 0 support #2506
I'd like to configure my grid node to use port 0 so that the OS selects a free port from the ephemeral range, and then I will communicate that port with another process so it can join the cluster.
I am having trouble doing this with Hazelcast 2.5. When I configure node A with port 0 and start it, the OS selects a port but that port is never looked at by AddressPicker. AddressPicker keeps port 0 in its bindAddress and publicAddress instead of looking at the ServerSocket to see the actual chosen port.
I can go find out what that port is using this major hack:
But if I then tell node B to join a cluster using that port, node A rejects the connection with this message:
Is this something which shoud be supported?
referenced this issue
May 20, 2014
Re: added value. Without this feature, a port must be chosen with fingers crossed that by the time hz tries to bind to it, some other process on the box has not stolen it causing transient failure.
Re: "how can another instance find that port" - indeed after hz node starts I would need a way to programaically find out which port was chosen by the OS so I can communicate that port to others.
Re: "Even if we can find a random port for the hz instance" -- to avoid possible confusion, hz code does not need to choose a port it can pass 0 to OS and OS will choose. hz just needs to support user passing port 0, then let user find out which port OS chose.