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

[discovery] HazelcastClient always tries to connect to localhost when using DiscoveryStrategy #10606

Closed
pvgoddijn opened this issue May 17, 2017 · 0 comments

Comments

@pvgoddijn
Copy link

@pvgoddijn pvgoddijn commented May 17, 2017

(HazelcastClient version 3.8)

When using the Discovery system to locate nodes the DefaultAddressProvider still get added to the addressProviders list causing the hazelcast(client) to try to connect to localhost. This is both unneeded and unwanted when using for example the MulticastDiscoveryStrategy.

In com.hazelcast.client.impl.HazelcastClientInstanceImpl.createAddressProviders ~ line 265
the DefaultAddressProvider get added which has a instance of ClientNetworkConfig
Because ClientNetworkConfig ~ line 212 alway returns a list with localhost if nothing is specified we end up with a Client that always connect to localhost unless a explict address is provided (which is unwanted in many discovery cases).

Proposed solution:
only include DefaultAddresProviders if no others are provided.

psuedo patch:

src/main/java/com/hazelcast/client/impl/HazelcastClientInstanceImpl.java
- 264: addressProviders.add(new DefaultAddressProvider(networkConfig));

+ 281:  if (addressProviders.isEmpty()) {
 + 282    	addressProviders.add(new DefaultAddressProvider(networkConfig));
 + 283: }

Reproducable by using any DiscoveryStrategy and not adding addresses to the clientconfig.xml

example client config:
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.8.xsd"
           xmlns="http://www.hazelcast.com/schema/client-config"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <group>
        <name>hazelcast-dev</name>
        <password>dev-pass</password>
    </group>
    <network>
	<aws enabled="false"/>
	<connection-timeout>10000</connection-timeout>
	<connection-attempt-period>500</connection-attempt-period>
	<connection-attempt-limit>20000</connection-attempt-limit>
    <smart-routing>true</smart-routing>
    <redo-operation>true</redo-operation>
	<discovery-strategies>
		<discovery-strategy class="com.hazelcast.spi.discovery.multicast.MulticastDiscoveryStrategy" enabled="true" >
			<properties>
				<property name="port" >9999</property>
				<property name="group" >230.18.0.255</property>
			</properties>
		</discovery-strategy>
	</discovery-strategies>
</network>
@pvgoddijn pvgoddijn changed the title DefaultAddressProvider added when unwanted HazelcastClient always tries to connect to localhost when using DiscoveryStrategy May 18, 2017
@mmedenjak mmedenjak changed the title HazelcastClient always tries to connect to localhost when using DiscoveryStrategy [discovery] HazelcastClient always tries to connect to localhost when using DiscoveryStrategy Jul 13, 2017
@sancar sancar added the Type: Defect label Aug 1, 2017
@sancar sancar added this to the 3.9 milestone Aug 1, 2017
@ihsandemir ihsandemir self-assigned this Aug 18, 2017
ihsandemir added a commit to ihsandemir/hazelcast that referenced this issue Aug 18, 2017
…y if only no other provider is configured (inlcuding aws and discovery strategy config), and no member tcp/ip address is added in the config.

ClientDiscoveryTest is added to test the test factory. The real network test is at ClientDiscoverySpiTest.

fixes hazelcast#10606
ihsandemir added a commit to ihsandemir/hazelcast that referenced this issue Aug 21, 2017
…y if only no other provider is configured (inlcuding aws and discovery strategy config), and no member tcp/ip address is added in the config.

ClientDiscoveryTest is added to test the test factory. The real network test is at ClientDiscoverySpiTest.

fixes hazelcast#10606
ihsandemir added a commit to ihsandemir/hazelcast that referenced this issue Aug 22, 2017
…y if only no other provider is configured (inlcuding aws and discovery strategy config), and no member tcp/ip address is added in the config.

ClientDiscoveryTest is added to test the test factory. The real network test is at ClientDiscoverySpiTest.

Updated testWithLegalAndIllegalAddressTogether test to work with the correct member port address configuration.

fixes hazelcast#10606
ihsandemir added a commit that referenced this issue Aug 22, 2017
…d and the discovery is configured (#11146)

* The client now adds the localhost to the address list very selectively if only no other provider is configured (inlcuding aws and discovery strategy config), and no member tcp/ip address is added in the config.

Updated testWithLegalAndIllegalAddressTogether test to work with the correct member port address configuration.

fixes #10606

* Fix for the testAsyncStartTrueXmlConfig so that the xml does not list any member since it will be provided by the hazelcast test factory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.