Skip to content

No alive nodes found in your cluster #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zakiaziz opened this issue Dec 6, 2016 · 8 comments
Closed

No alive nodes found in your cluster #509

zakiaziz opened this issue Dec 6, 2016 · 8 comments

Comments

@zakiaziz
Copy link

zakiaziz commented Dec 6, 2016

Summary of problem or feature request

I have a laravel app (v5.1) and I'm actually using this library: https://github.com/elasticquent/Elasticquent which is a wrapper around elasticsearch-php. The app is hosted on an EC2 instance and doing a cURL request from there returns a response:

$ curl search-instance-name-912ec803b2ce49.us-east-1.es.amazonaws.com
{
  "name" : "Agent Axis",
  "cluster_name" : 1234567890:instance-name",
  "version" : {
    "number" : "2.3.2",
    "build_hash" : "0ab538e92c6db78d10b1694e645f3625",
    "build_timestamp" : "2016-11-14T15:59:50Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}

Elasticquent gives a way to insert records from a DB into elasticsearch and that's the code which is returning an error. (below)

Code snippet of problem

$products = Products::addAllToIndex();
$files = File::addAllToIndex();

Here is a gist of the exception stack trace incase it helps: https://gist.github.com/zakiaziz/1fa94f9c3f504a5a9bc756ebd96f9065

I've tried changing my host to https://search-instance-name-912ec803b2ce49.us-east-1.es.amazonaws.com:443 but no luck. also tried putting in a newer version (2.3.0) in composer.json with no luck

System details

  • Operating System: Ubuntu 14.04
  • PHP Version: 5.5.9
  • ES-PHP client version: v2.1.5
  • Elasticsearch version: 2.3
@polyfractal
Copy link
Contributor

To be honest, I'm not super familiar with AWS ES. That error basically means it can't find your cluster, likely due to misconfiguration on either the client's side or the server's side. How have you configured access control to the cluster?

You may need to use the extended host config syntax

E.g.

$hosts = [
    [
        'host' => 'search-instance-name-912ec803b2ce49.us-east-1.es.amazonaws.com',
        'port' => '443',
        'scheme' => 'https',
        //'user' => 'username',  //not sure if you need these on AWS?
       // 'password' => 'password!#$?*abc'
    ]
];
$client = ClientBuilder::create()           // Instantiate a new ClientBuilder
                    ->setHosts($hosts)      // Set the hosts
                    ->build();              // Build the client object

You might also try dropping the port 443, because there was (at least at one time) issues with how AWS validates authentication via canocalized URLS (see #309)

So maybe try this:

$hosts = [
    [
        'host' => 'search-instance-name-912ec803b2ce49.us-east-1.es.amazonaws.com',
        'scheme' => 'https'
    ]
];
$client = ClientBuilder::create()           // Instantiate a new ClientBuilder
                    ->setHosts($hosts)      // Set the hosts
                    ->build();              // Build the client object

@zakiaziz
Copy link
Author

zakiaziz commented Dec 6, 2016

I've tried that but to no avail. I have another server on Linode that I use for development. Putting in the AWS ES endpoint there and running the commands from there works and properly indexes the documents. I'm thinking this issue is related to either a server configuration, that a possibility?

@polyfractal
Copy link
Contributor

Hm ok. Time to roll up the sleeves and start debugging :)

Can you try running a request with verbose toggled on, and checking the last-connection info? Like this:

$params = [ 
 // set your params here
];

// toggle verbosity
$params['client']['verbose'] = true;

try {
  $response = $client->index($params);
  print_r($response);
catch (Exception $e) {
  $last = $client->transport->getLastConnection()->getLastRequestInfo();
  $last['response']['error'] = [];
  print_r($last);
}

I'm not quite sure how you'll do that with Laravel, but basically we want to add ['client']['verbose'] to the request parameters, then either print out the response directly, or catch the exception and grab some debug info (and print that).

Also make sure you're on the most recent version of ES-PHP, just to simplify debugging (v2.3).

Another option is to try using CurlCaBundle or Composer/ca-bundle instead of the SSL certs on your system... just in case they are out of date or something similar. You can find more information regarding using them with the client here: https://www.elastic.co/guide/en/elasticsearch/client/php-api/5.0/_security.html#_public_ca_certificates

@polyfractal
Copy link
Contributor

Oh, another option is to go back to HTTP like you first tried, but explicitly set the port to 80. The client defaults HTTP connections to 9200 because that's what ES uses by default, but I seem to remember that the AWS service uses 80 instead.

@bluesky4485
Copy link

I have the same problem when using Elasticsearch 5.1.1.
I just flow the elasticsearch/client/php-api/quickstart with elasticsearch-php v5.0

@callumjh009
Copy link

I've also run into this issue using the elasticsearch php client. AWS ES only runs over port 80 or 443 using a REST API and doesn't support the ES Transport protocol by default (http://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html) . The only way to get the client working seems to be to set it to http and to manually set the port to 80. Can't seem to get https and port 443 working. Shame Amazon don't offer proper client libraries or support existing ones.

$client_builder = ClientBuilder::create();
$client_builder->setHosts(['http://XXX.eu-west-1.es.amazonaws.com:80']);
$this->client = $client_builder->build();

@benanderton
Copy link

For anyone struggling for an answer I came across an issue with this today. I'm using Docker and had internal hostnames with underscores (ie, portal_elasticsearch). I raised a question on Stack Overflow before realising that the elasticsearch PHP API won't work with underscores in host names (as it probably shouldn't, in all honesty) without some faffing.

There's more of an explanation on SO - https://stackoverflow.com/questions/56111471/hostname-resolution-not-working-from-within-elasticsearch-client-under-docker/56113504#56113504

@ezimuel
Copy link
Contributor

ezimuel commented Jul 12, 2019

Outdated issue. @zakiaziz if this still relevant I'll reopen it.

@ezimuel ezimuel closed this as completed Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants