Skip to content

Java-REST-Client NodeSniffer Fails parsing publish_address properly #48950

@UglyBarnacle

Description

@UglyBarnacle

Elasticsearch version (bin/elasticsearch --version): 7.4.2 - Java Client 7.4.2

Plugins installed: []

JVM version (java -version): jdk11

OS version (uname -a if on a Unix-like system): unix docker

Description of the problem including expected versus actual behavior:
Node-Sniffer for Java-Rest-Client fails parsing the new hostname/ip:port format properly.
Client is initalized with a consul-address containing the port. instead the hostname is just used with port 80, the sniff() fails with an ConnectionException.
=> expected IP and port are extracted 192.168.0.185:9202
=> actual only hostname is parsed integration-stack-01.com.pany

Steps to reproduce:

Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.

  1. setup clusternode with hostname so publish_address : "integration-stack-01.com.pany/192.168.0.185:9202"
  2. create simple main-Class Java starting a Client and Sniffer
  3. Sniffer fails at sniff() because address is parsed not properly

Provide logs (if relevant):

GET http://elasticsearch3.service.int.consul:9202/_nodes/http?pretty
{
  "_nodes" : {
    "total" : 3,
    "successful" : 3,
    "failed" : 0
  },
  "cluster_name" : "company-int-3",
  "nodes" : {
    "qGSyScvjRK2jbujcpo9t3g" : {
      "name" : "integration-stack-01",
      "transport_address" : "192.168.0.185:9302",
      "host" : "integration-stack-01.com.pany",
      "ip" : "192.168.0.185",
      "version" : "7.4.2",
      "build_flavor" : "default",
      "build_type" : "tar",
      "build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
      "roles" : [
        "ingest",
        "master",
        "data",
        "ml"
      ],
      "attributes" : {
        "ml.machine_memory" : "67498500096",
        "ml.max_open_jobs" : "20"
      },
      "http" : {
        "bound_address" : [
          "[::]:9202"
        ],
        "publish_address" : "integration-stack-01.com.pany/192.168.0.185:9202",
        "max_content_length_in_bytes" : 104857600
      }
    },
	...

Error:

16:46:03.278 [pool-1-thread-1] DEBUG org.apache.http.impl.nio.client.InternalHttpAsyncClient - [exchange: 13] connection request failed
16:46:03.278 [pool-1-thread-1] DEBUG org.elasticsearch.client.RestClient - request [GET http://integration-stack-03.com.pany/_nodes/http?timeout=1000ms] failed

Example:

package com.pany.elasticsearchrestclients;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.sniff.SniffOnFailureListener;
import org.elasticsearch.client.sniff.Sniffer;

public class TestStarter
{
	public static void main(final String[] args)
	{
		SniffOnFailureListener sniffOnFailureListener = new SniffOnFailureListener();
		RestClientBuilder builder = RestClient.builder(new HttpHost("elasticsearch3.service.int.consul", 9202)).setFailureListener(sniffOnFailureListener);
		RestHighLevelClient client = new RestHighLevelClient(builder);
		Sniffer sniffer = Sniffer.builder(client.getLowLevelClient()).setSniffAfterFailureDelayMillis(1_000).setSniffIntervalMillis(500).build();
		sniffOnFailureListener.setSniffer(sniffer);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions