elastic / elasticsearch-php

Official PHP client for Elasticsearch.
https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html
MIT License
5.26k stars 965 forks source link

Request port missing from URL in log messages #1113

Closed pmishev closed 3 years ago

pmishev commented 3 years ago

Likely related to #925, but since that one is close as fixed, I'm submitting a new issue, in case it's a different problem:

Version: 7.11.0

        $tracer = new Logger('es');
        $tracer->pushHandler(new StreamHandler('trace.log', Logger::DEBUG));

        $clientBuilder = ClientBuilder::create();
        $clientBuilder->setHosts(['192.168.56.115:9200']);
        $clientBuilder->setTracer($tracer);

        $client = $clientBuilder->build();
        $res = $client->indices()->getAlias(['name' => 'blah']);

trace.log contains:

[2021-03-09 15:18:54] es.INFO: curl -XGET 'http://192.168.56.115/_alias/blah?pretty=true' [] []
[2021-03-09 15:18:54] es.DEBUG: Response: {"response":{"transfer_stats":{"url":"http://192.168.56.115/_alias/blah","content_type":"application/json; charset=UTF-8","http_code":404,"header_size":93,"request_size":285,"filetime":-1,"ssl_verify_result":0,"redirect_count":0,"total_time":0.00455,"namelookup_time":5.2e-5,"connect_time":0.000904,"pretransfer_time":0.00118,"size_upload":0,"size_download":45,"speed_download":11250,"speed_upload":0,"download_content_length":45,"upload_content_length":-1,"starttransfer_time":0.004478,"redirect_time":0,"redirect_url":"","primary_ip":"192.168.56.115","certinfo":[],"primary_port":9200,"local_ip":"192.168.56.111","local_port":59218,"http_version":2,"protocol":1,"ssl_verifyresult":0,"scheme":"HTTP","error":"","errno":0},"curl":{"error":"","errno":0},"effective_url":"http://192.168.56.115/_alias/blah","headers":{"content-type":["application/json; charset=UTF-8"],"content-length":["45"]},"version":"1.1","status":404,"reason":"Not Found","body":"{\"error\":\"alias [blah] missing\",\"status\":404}"},"method":"GET","uri":"http://192.168.56.115/_alias/blah","HTTP code":404,"duration":0.00455} []

The port is still missing from the URLs. It should be: http://192.168.56.115:9200/_alias/blah, not http://192.168.56.115/_alias/blah

ezimuel commented 3 years ago

@pmishev the issue seems to be in Connection::buildCurlCommand() since I don't pass the port value to build the cURL command. The port value (9200) is reported in response.transfer_stats.primary_port. These are the DEBUG information reported by cURL. We removed the port in the Host because of this issue. I'll fix this asap, thanks for reporting.

ezimuel commented 3 years ago

@pmishev I just sent this PR https://github.com/elastic/elasticsearch-php/pull/1126 to fix the issue. Let me know if you can try it, thanks!

pmishev commented 3 years ago

Thank you @ezimuel. I tried it and as far as I can tell it works as expected.

ezimuel commented 3 years ago

Merged #1126 . This will be released with 7.13.0.

pmishev commented 3 years ago

What happened with this PR? It doesn't seem to be merged in 7.13.0?

ezimuel commented 3 years ago

@pmishev I didn't cherry-pick this to 7.13 branch, sorry for that. I'm going to provide a patch release 7.13.1 including #1126.

ezimuel commented 3 years ago

@pmishev just released elasticsearch-php 7.13.1 including #1126.