mailerlite / laravel-elasticsearch

An easy way to use the official Elastic Search client in your Laravel applications.
MIT License
909 stars 187 forks source link

no response with Laravel 8, PHP8.0 #126

Closed sp-clariondoor closed 2 years ago

sp-clariondoor commented 2 years ago

I recently updated our laravel application to php8.0 and cviebrock/laravel-elasticsearch complained about it and updated the following packages:

    "php": "^8.0",
    "aws/aws-sdk-php-laravel": "^3.6",
    "cviebrock/laravel-elasticsearch": "8.0.4",
    "elasticsearch/elasticsearch": "7.11",
    "guzzlehttp/guzzle": "^7.0.1",
    "laravel/framework": "^8.61",

but I got the error as :

.../vendor/cviebrock/laravel-elasticsearch/src/Factory.php:167
.../vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:265
.../vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:241
.../vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php:110
.../vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/AbstractNamespace.php:63
.../vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/IndicesNamespace.php:512
.../app/Services/ElasticsearchClient.php:170
.../app/Services/ElasticsearchClient.php:48

and after more digging into the code, I found this function doesn't return any response and end up with a timeout

                    // Send the signed request to Amazon ES
                    $response = $psr7Handler($signedRequest, ['http_stats_receiver' => $http_stats])
                        ->then(function(ResponseInterface $response) {
                            return $response;
                        }, function($error) {
                            return $error['response'];
                        })
                        ->wait();

any idea how I can fix this issue?

Thanks

sp-clariondoor commented 2 years ago

@cviebrock it took me forever to figure it out.... in Factory.php https://github.com/cviebrock/laravel-elasticsearch/blob/626e428497a87bb96d743fa40a25620d24225a4b/src/Factory.php#L109
you added this line inside the AWS ES block (if host is AWS) . not sure why AWS URL needs a port! but if it's needed you should add a comment for the config file to not add port number inside the config file

to solve the issue with the current code, we should use port=>null instead of port=>9200 or remove line 109 in the Factory.PHP if it's not needed

marcellofuschi commented 2 years ago

@cviebrock, any updates on this?

Quite an impeding problem for a newcomer or someone who accidentally leaves the port included in the config.

cviebrock commented 2 years ago

Added the comments in 8.0.6