Cannot create a Transport Client in Java API


(Aymen Zaghouani) #1

I've recently started exploring the world of search, and am trying to use ES as the index for my MongoDB. I've managed to integrate them successfully, but I find the search API rather complex and confusing. The Java API is not too helpful either

I started by creating a Transport like this :

Settings settings = ImmutableSettings.settingsBuilder()
.put("cluster.name", "elasticsearch").build();
Client clientC = new TransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress("host-ip", 9300));

and I'm getting this error :

java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:123)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:621)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink.connect(NioClientSocketPipelineSink.java:108)
at org.elasticsearch.common.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:70)
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:574)
at org.elasticsearch.common.netty.channel.Channels.connect(Channels.java:634)
at org.elasticsearch.common.netty.channel.AbstractChannel.connect(AbstractChannel.java:216)
at org.elasticsearch.common.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:229)
at org.elasticsearch.common.netty.bootstrap.ClientBootstrap.connect(ClientBootstrap.java:182)
at org.elasticsearch.transport.netty.NettyTransport.connectToChannelsLight(NettyTransport.java:759)
at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:727)
at org.elasticsearch.transport.netty.NettyTransport.connectToNodeLight(NettyTransport.java:699)
at org.elasticsearch.transport.TransportService.connectToNodeLight(TransportService.java:220)
at org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler.doSample(TransportClientNodesService.java:343)
at org.elasticsearch.client.transport.TransportClientNodesService$NodeSampler.sample(TransportClientNodesService.java:289)
at org.elasticsearch.client.transport.TransportClientNodesService.addTransportAddresses(TransportClientNodesService.java:172)
at org.elasticsearch.client.transport.TransportClient.addTransportAddress(TransportClient.java:241)


(Jason Wee) #2

Looks like it has nothing to do with the java api, it just that host-ip cannot resolve to a valid ip, are you host-ip is resolvable by the machine that executed the client code?


(system) #3