Search code examples
ignite

Apache ignite client app doesn't find the server cluster


I'm using the configuration below, with a cluster running on my local machine with the same port range as below (37500..37509)

IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setClientMode(true);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setMulticastGroup("127.0.0.1");
// Set initial IP addresses.
// Note that you can optionally specify a port or a port range.
ipFinder.setAddresses(Arrays.asList("127.0.0.1:37500..37509"));
spi.setLocalPort(37508);
spi.setLocalPortRange(0);

TcpCommunicationSpi commSpi=new TcpCommunicationSpi();

commSpi.setLocalPort(37509);

// Overriding discovery SPI.
cfg.setDiscoverySpi(spi);

// Overriding communication SPI.
cfg.setCommunicationSpi(commSpi);
try (Ignite ig = Ignition.start(cfg)) {
    IgniteCache<Integer, String> cache = ig.getOrCreateCache("myCacheName");
    cache.put(1, "vlad");
    cache.get(1);
}

I'm getting the below error message:

[17:51:14] IP finder returned empty addresses list. Please check IP finder configuration and make sure multicast works on your network. Will retry every 2 secs.

Any thoughts?


Solution

  • The error itself is shown because you didn't set the IP finder to the discovery SPI (spi.setIpFinder(ipFinder)).

    However, you should also note that DiscoverySpi and CommunicationSpi are two different components and they use different ports. What you did here is bound communication to one of the ports discovery will try to connect to. Port ranges for discovery and communication should not intersect.