Skip to content

Library should make an effort to report low-level network errors #1308

Closed
@croensch

Description

@croensch

Summary of problem or feature request

The transport or pool should make an effort to report low-level network errors that lead to NoNodeAvailableException.

There have been a couple of issues and stackoverflow questions, that often ultimately resolved in "My nodes ARE available - it's the client that can't connect" often due to misconfiguration or circumstances (wrong host, self-signed HTTPS, Firewalls, Proxies, etc.). Since this library uses cURL by default it would be proper to wrap the cURL error into this exception.

Code snippet of problem

This does not help:

        try {
            $info = $this->esClient->info();
            $this->logger->info('ES: Info', ['info' => $info->asArray()]);
        } catch (NoNodeAvailableException $exception) {
            $lastResponse = $this->esClient->getTransport()->getLastResponse();
            $status = $lastResponse->getStatusCode();
            $reason = $lastResponse->getReasonPhrase();
            $contents = $lastResponse->getBody()->getContents();
            $this->logger->error('ES: Info not available', ['exception' => $exception, 'status' => $status, 'reason' => $reason, 'contents' => $contents]);
        } catch (ElasticsearchException $e) {
            $this->logger->warning('ES: Info not retrieved', ['exception' => $e]);
        }

Because Transport.lastResponse is not set.

System details

  • Linux
  • PHP 8.1
  • ES-PHP 8.x
  • Elasticsearch 8.x

Metadata

Metadata

Assignees

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