I am using code exactly which you share in link with 9243,9343 port.Please find code and exception below.Also tried with public network.
Code :
public class TransportExample {
public Logger logger = ESLoggerFactory.getLogger(getClass().getCanonicalName());
// Note: If enabling IPv6, then you should ensure that your host and network can route it to the Cloud endpoint.
// (eg Docker disables IPv6 routing by default) - see also the system property parsing code below.
private boolean ip6Enabled = true;
private boolean ip4Enabled = true;
public static void main(String[] args) {
new TransportExample().run(args);
}
public void run(String[] args) {
String host = "2160c0d4e57ff12912f8aaaaaaaaaaaa.us-east-1.aws.found.io";
int port = Integer.parseInt(System.getProperty("port", "9343"));
String hostBasedClusterName = host.split("\\.", 2)[0];
String clusterName = System.getProperty("cluster", hostBasedClusterName);
boolean enableSsl = Boolean.parseBoolean(System.getProperty("ssl", "true"));
// Note: If enabling IPv6, then you should ensure that your host and network can route it to the Cloud endpoint.
// (eg Docker disables IPv6 routing by default) - see also the initialization code at the top of this file.
ip6Enabled = Boolean.parseBoolean(System.getProperty("ip6", "true"));
ip4Enabled = Boolean.parseBoolean(System.getProperty("ip4", "true"));
logger.info("Connecting to cluster: [{}] via [{}:{}] using ssl:[{}]", clusterName, host, port, enableSsl);
// Build the settings for our client.
Settings settings = Settings.builder()
.put("client.transport.nodes_sampler_interval", "5s")
.put("client.transport.sniff", false)
.put("transport.tcp.compress", true)
.put("cluster.name", clusterName)
.put("xpack.security.transport.ssl.enabled", enableSsl)
.put("request.headers.X-Found-Cluster", "${cluster.name}")
.put("xpack.security.user", "username:password")
.build();
// Instantiate a TransportClient and add the cluster to the list of addresses to connect to.
// Only port 9343 (SSL-encrypted) is currently supported. The use of X-Pack security features (formerly Shield) is required.
TransportClient client = new PreBuiltXPackTransportClient(settings);
try {
for (InetAddress address : InetAddress.getAllByName(host)) {
if ((ip6Enabled && address instanceof Inet6Address)
|| (ip4Enabled && address instanceof Inet4Address)) {
client.addTransportAddress(new InetSocketTransportAddress(address, port));
}
}
} catch (UnknownHostException e) {
logger.error("Unable to get the host", e.getMessage());
}
while(true) {
try {
logger.info("Getting cluster health... ");
ActionFuture<ClusterHealthResponse> healthFuture = client.admin().cluster().health(Requests.clusterHealthRequest());
ClusterHealthResponse healthResponse = healthFuture.get(5, TimeUnit.SECONDS);
logger.info("Got cluster health response: [{}]", healthResponse.getStatus());
} catch(Throwable t) {
logger.error("Unable to get cluster health response: [{}]", t.getMessage());
}
try {
Thread.sleep(1000);
} catch (InterruptedException ie) { ie.printStackTrace(); }
}
}
}
Exception:
08:25:01.339 [main] ERROR javaapplication21.TransportExample - Unable to get cluster health response: [None of the configured nodes are available: [{#transport#-1}{ZFOMH60GQgKMdxQMbzxY7Q}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{50.16.214.212:9343}, {#transport#-2}{HJi0ZrhvQuyxXbmmMS-fPg}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{54.204.11.42:9343}, {#transport#-3}{vKEGIwwJQ6uzUG55kfVvMA}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{54.197.233.100:9343}, {#transport#-4}{0qTkNoKORrW-AHcZVomvMQ}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{54.225.145.66:9343}, {#transport#-5}{NOHIVbq0Q--uPDF8jG-KYw}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{54.235.188.40:9343}, {#transport#-6}{KZ7bCyrbTh6N21z06fLPYg}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{54.243.142.98:9343}, {#transport#-7}{zSDlpeH1TDCdMmSRnIhKiA}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{50.17.198.49:9343}, {#transport#-8}{ZOY_xv1GRTua5pJRbkTpAQ}{2160c0d4e57ff12912f8c2798a4e7485.us-east-1.aws.found.io}{54.225.154.35:9343}]]
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.