Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port 0 support #2506

Closed
brianfromoregon opened this issue May 20, 2014 · 2 comments

Comments

Projects
None yet
8 participants
@brianfromoregon
Copy link

commented May 20, 2014

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:

    HazelcastInstance instance = …
    FactoryImpl factoryImpl = (FactoryImpl)((FactoryImpl.HazelcastInstanceProxy)instance).getHazelcastInstance();
    Field channelField = ReflectionUtils.findField(ConnectionManager.class, "serverSocketChannel");
    ServerSocketChannel channel = (ServerSocketChannel) ReflectionUtils.getField(channelField, factoryImpl.node.connectionManager);
    int peerPort = ((InetSocketAddress) channel.getLocalAddress()).getPort();

But if I then tell node B to join a cluster using that port, node A rejects the connection with this message:

WARNING: [127.0.0.1]:0 [Test] Wrong bind request from Address[127.0.0.1]:0! This node is not requested endpoint: Address[127.0.0.1]:52828

Is this something which shoud be supported?

@pveentjer

This comment has been minimized.

Copy link
Member

commented May 21, 2014

For my understanding: what would be the added value? Even if we can find a random port for the hz instance, how can another instance find that port? So help me to understand the added value.

@degerhz degerhz added the Team: Core label Oct 14, 2014

@ahmetmircik ahmetmircik added this to the 3.4 milestone Nov 24, 2014

@ahmetmircik ahmetmircik removed the PENDING label Nov 24, 2014

@enesakar enesakar modified the milestones: 3.4, 3.4.1 Nov 25, 2014

@mdogan mdogan modified the milestones: 3.4.1, 3.5 Nov 27, 2014

@gurbuzali gurbuzali modified the milestones: Backlog, 3.5 May 13, 2015

@brianfromoregon

This comment has been minimized.

Copy link
Author

commented Jul 15, 2015

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.