Closed ahmeteminkocal closed 10 months ago
Hey @ahmeteminkocal, I tried to reproduce the issue, but it seems to be working just fine with the latest versions of the packages. This is what I use on my local setup:
babenkoivan/elastic-adapter v3.5.0 Adapter for official PHP Elasticsearch client
babenkoivan/elastic-client v2.1.0 The official PHP Elasticsearch client integrated with Laravel
babenkoivan/elastic-scout-driver v3.1.0 Elasticsearch driver for Laravel Scout
elastic/transport v8.8.0 HTTP transport PHP library for Elastic products
elasticsearch/elasticsearch v8.11.0 PHP Client for Elasticsearch
guzzlehttp/guzzle 7.8.1 Guzzle is a PHP HTTP client library
guzzlehttp/promises 2.0.2 Guzzle promises library
guzzlehttp/psr7 2.6.2 PSR-7 message implementation that also provides common utility methods
php-http/discovery 1.19.2 Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations
php-http/httplug 2.4.0 HTTPlug, the HTTP client abstraction for PHP
php-http/promise 1.2.1 Promise used for asynchronous HTTP requests
psr/http-client 1.0.3 Common interface for HTTP clients
psr/http-factory 1.0.2 Common interfaces for PSR-7 HTTP message factories
psr/http-message 2.0 Common interface for HTTP messages
psr/log 3.0.0 Common interface for logging libraries
ralouphie/getallheaders 3.0.3 A polyfill for getallheaders.
symfony/deprecation-contracts v3.4.0 A generic function and convention to trigger deprecation notices
Can you please ensure you use the latest versions of all dependencies (especially psr/http-message
, which should be at least 2.0)?
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days
Describe the bug There are multiple incompatibilities and bugs on the library with latest version laravel. I received these PSR Compatibility errors.
[2023-11-21 19:23:33] production.ERROR: Declaration of Elastic\Elasticsearch\Response\Elasticsearch::getHeader(string $name): array must be compatible with Psr\Http\Message\MessageInterface::getHeader($name) {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Declaration of Elastic\\Elasticsearch\\Response\\Elasticsearch::getHeader(string $name): array must be compatible with Psr\\Http\\Message\\MessageInterface::getHeader($name) at /var/www/html/vendor/elasticsearch/elasticsearch/src/Traits/MessageResponseTrait.php:47)
Also [2023-11-21 19:23:46] production.ERROR: No alive nodes. All the 1 nodes seem to be down. {"exception":"[object] (Elastic\Transport\Exception\NoNodeAvailableException(code: 0): No alive nodes. All the 1 nodes seem to be down. at /var/www/html/vendor/elastic/transport/src/NodePool/SimpleNodePool.php:77) errors even though the node worked fine.As a solution I replaced variable types from functions to resolve the first problem, and it worked. For example on getHeader(string $name) I replaced it with getHeader($name). It gave the same error on other functions and I replaced them as well. Also for the second error, I have updated this section;
As you can see it will return the node without checking if it is up or down. Doing so will allow it to access it. So there is a false exception going here.
Right now it is working fine.
As a summary there are two problems;