简体   繁体   中英

elasticsearch php client omit port on host

I'm creating a project that needs to have elasticsearch inbound, I'm using elasticsearch/elasticsearch package to handle the elasticsearch stuff using php. Now in the readme file I get the following:

$hosts = [
     '192.168.1.1:9200',         // IP + Port
     '192.168.1.2',              // Just IP
     'mydomain.server.com:9201', // Domain + Port
     'mydomain2.server.com',     // Just Domain
     'https://localhost',        // SSL to localhost
     'https://192.168.1.3:9200'  // SSL to IP + Port
];
$client = ClientBuilder::create()           
                    ->setHosts($hosts)      // Set the hosts
                    ->build();              // Build the client object

And if I use as a host the IP address of my host without the port then the port 9200 is appended to the url that I request in every case. My ES server is listening on port 80 and there is no need to put the port to connect to it.

My connection definition is as follows:

$params = [
    'hosts' => [
        'XXX.XXX.XXX.XXX'
    ],
    'retries' => 5
];

return ClientBuilder::fromConfig($params);

And then the client throws an exception NoNodesAvailableException and crawling on the exception trace I see that the connection is being made at 'url' => ' http://XXX.XXX.XXX.XXX :9200 /

How to get rid of the 9200, the ES node is working If I do:

http://XXX.XXX.XXX.XXX/?pretty I get

{
    "status" : 200,
    "name" : "568402dd7628e13d38000138",
    "cluster_name" : "elasticsearch-568402dd7628e13d38000138",
    "version" : {
        "number" : "1.7.1",
        "build_hash" : "b88f43fc40b0bcd7f173a1f9ee2e97816de80b19",
        "build_timestamp" : "2015-07-29T09:54:16Z",
        "build_snapshot" : false,
        "lucene_version" : "4.10.4"
    },
    "tagline" : "You Know, for Search"

}

So, what can be happening that the 9200 is never removed if not specified. If I put XXX.XXX.XXX.XXX:80 then it won't work as well.

It looks like defining the full qualified URL https://example.com:443 worked. Thanks all for the answers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM