Skip to content

"No alive nodes found in your cluster" using v2.1.4 release with ES 1.7 #376

@rjbaker

Description

@rjbaker

Hi There,

I'm getting the following error when attempting to connect to ES 1.7 to run a scroll/scan operation.

I'm using an ES cluster hosted by Qbox.io accessed via a client node. I'm able to connect fine using a standard rest client and also the 1.0 branch of the client library.

Fatal error: Uncaught exception 'Elasticsearch\Common\Exceptions\NoNodesAvailableException' with message 'No alive nodes found in your cluster' in /Users/richardbaker/Documents/Development/project/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php:51
Stack trace:
#0 /Users/richardbaker/Documents/Development/project/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(71): Elasticsearch\ConnectionPool\StaticNoPingConnectionPool->nextConnection()
#1 /Users/richardbaker/Documents/Development/project/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Transport.php(89): Elasticsearch\Transport->getConnection()
#2 /Users/richardbaker/Documents/Development/project/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php(230): Elasticsearch\Transport->performRequest('GET', '/_search/scroll...', Array, NULL, Array)
#3 /Users/richardbaker/Documents/Development/project/vendor/react/promise/src/Fulf in /Users/richardbaker/Documents/Development/project/vendor/elasticsearch/elasticsearch/src/Elasticsearch/ConnectionPool/StaticNoPingConnectionPool.php on line 51

My code is basically ripped from the client library example:

require 'vendor/autoload.php';

$source_hosts = [
    'https://user:long$passwor?d@clientnode-instance-hostname.qbox.io:443'
];

$source_client = Elasticsearch\ClientBuilder::create()
    ->setHosts($source_hosts)->build();

// Scan/Scroll Query
$source_params = [
    "search_type" => "scan",    // use search_type=scan
    "scroll" => "30s",          // how long between scroll requests. should be small!
    "size" => 50,               // how many results *per shard* you want back
    "index" => "alerts-1-1",
    "type" => "alert",
    "body" => [
        "query" => [
            "filtered" => [
                "query" => [
                    "match_all" => []
                ],
                "filter" => [
                    "range" => [
                        "timestamps.created" => [
                            "gte" => "now-10d"
                        ]
                    ]
                ]
            ]
        ]
    ]
];

$total = 0;
$docs = $source_client->search($source_params);
$scroll_id = $docs['_scroll_id'];

while (true)
{
    // Execute a Scroll request
    $response = $source_client->scroll([
            "scroll_id" => $scroll_id,  //...using our previously obtained _scroll_id
            "scroll" => "30s"           // and the same timeout window
        ]
    );

    // Check to see if we got any search hits from the scroll
    if (count($response['hits']['hits']) > 0)
    {
        $total += count($response['hits']['hits']);

        // Get new scroll_id
        // Must always refresh your _scroll_id!  It can change sometimes*/
        $scroll_id = $response['_scroll_id'];
        echo "Completed: " . $total . PHP_EOL;
    }
    else
    {
        // No results, scroll cursor is empty.  You've exported all the data
        break;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions