matchish / laravel-scout-elasticsearch

Search among multiple models with ElasticSearch and Laravel Scout
MIT License
702 stars 113 forks source link

[BUG] NoNodeAvailableException: No alive nodes. All the 1 nodes seem to be down #246

Closed hazratmilad closed 1 year ago

hazratmilad commented 1 year ago

Describe the bug

node is alive and i can access by curl : curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200

but with api call :

NoNodeAvailableException: No alive nodes. All the 1 nodes seem to be down. in file /var/www/html/vendor/elastic/transport/src/NodePool/SimpleNodePool.php on line 77

Additional context

SCOUT_DRIVER=Matchish\ScoutElasticSearch\Engines\ElasticSearchEngine ELASTICSEARCH_HOST=https://localhost:9200 ELASTICSEARCH_USER=elastic ELASTICSEARCH_PASSWORD=O8loD2Uvy4-XDL-CIl2P

Version

Versions of Laravel 10, Scout 10, and the package 7.2.1.

matchish commented 1 year ago

The package use official elasticsearch client https://github.com/matchish/laravel-scout-elasticsearch/blob/5d83dd7dbcbaa77d13246a73014d930ef3144625/src/ElasticSearchServiceProvider.php#L24 I believe if you will instantiate the client by yourself you'll get the same error. Usually people have the issue because of wrong configuration

matchish commented 1 year ago

If you have some specific requirements to configuration you can implement your own ElasticSearchServiceProvider and register it https://github.com/matchish/laravel-scout-elasticsearch#rocket-installation

'providers' => [
    // Other Service Providers

    \Matchish\ScoutElasticSearch\ElasticSearchServiceProvider::class
],
kbiro-nander commented 10 months ago

@hazratmilad the problem is that you probably did not provide the SSL certificate of your Elastic instance.

You can run the Elastic image without the SSL certificate with the following options:

xpack.security.enabled=false discovery.type=single-node

docker run --name es01 --net elastic -p 9200:9200 -it -e "xpack.security.enabled=false" -e "discovery.type=single-node" -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.10.4

Do this only in your local environment!

Alternatively you can add the certificate to the laravel-scout-elasticsearch config.