Client PHP in local. Mistake. I can't connect to ElasticSearch 8.2

In a default installation with deb packages, I have ElasticSeacrh + Kibana installed by default. That is, with security (username and password), self-signed HTTPS.

When I tried to do my first connection test via PHP it failed.

use Elasticsearch\ClientBuilder;
... 

$hosts = [
    'host' => 'localhost',
    'port' => '9200',
    'scheme' => 'https',
];

$client = ClientBuilder::create()
    ->setHosts($hosts)
    ->setBasicAuthentication('elastic', '1iXGIbGHCFcknQLp6+rv')
    ->setSSLCert('/home/abkrim/Sites/sitelight/ssl/http_ca.crt')
    ->build();

        ray($client->info());  // ray is debug utilizy for PHP that show values in a special console
        ray($client->indices()); 

        return 0;
    }

On logs I see

[2022-05-22T09:30:33,168][WARN ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [abkrim-nox] received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/127.0.0.1:9200, remoteAddress=/127.0.0.1:38700}

What am I doing wrong? I thought that with the configuration passed in the scheme it should work.

Round away

If deactivate security in elastisearch, I don't problems with PHP client

xpack.security.enabled: false

xpack.security.enrollment.enabled: false

# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
  enabled: false

But after making these changes and restarting Elasticsearch, console Kibana does not work. Show message

{"statusCode":503,"error":"Service Unavailable","message":"License is not available."}

And logs show

{"ecs":{"version":"8.0.0"},"@timestamp":"2022-05-22T11:37:14.190+02:00","message":"License information could not be obtained from Elasticsearch due to ConnectionError: write EPROTO 140063329195968:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:\n error","log":{"level":"WARN","logger":"plugins.licensing"},"process":{"pid":54140},"trace":{"id":"6cd0cc555f3569f61db4764a9a3759c1"},"transaction":{"id":"89a7ec2a579c08b9"}}

Kibana does not work, but the PHP client yes if change code for use scheme HTTP, but work very, very slow (3 minutes for response)

$hosts = [
    'host' => 'localhost',
    'port' => '9200',
;
$client = ClientBuilder::create()
            ->setHosts($hosts)
            ->setBasicAuthentication('elastic', '1iXGIbGHCFcknQLp6+rv')
            ->build();

$params = ['index' => 'kibana_sample_data_logs'];
ray($client->info());
ray($client->indices()->getSettings($params));
```
Debugger sho

```
array:5 [▼
  "name" => "abkrim-nox"
  "cluster_name" => "elasticsearch"
  "cluster_uuid" => "E_d31aTxSaKlUIIQhOKZkw"
  "version" => array:9 [▼
    "number" => "8.2.0"
    "build_flavor" => "default"
    "build_type" => "deb"
    "build_hash" => "b174af62e8dd9f4ac4d25875e9381ffe2b9282c5"
    "build_date" => "2022-04-20T10:35:10.180408517Z"
    "build_snapshot" => false
    "lucene_version" => "9.1.0"
    "minimum_wire_compatibility_version" => "7.17.0"
    "minimum_index_compatibility_version" => "7.0.0"
  ]
  "tagline" => "You Know, for Search"
]
CommandIndex.php:57

11:48:07
array:1 [▼
  "kibana_sample_data_logs" => array:1 [▼
    "settings" => array:1 [▼
      "index" => array:8 [▼
        "routing" => array:1 [▶]
        "number_of_shards" => "1"
        "auto_expand_replicas" => "0-1"
        "provided_name" => "kibana_sample_data_logs"
        "creation_date" => "1653199167889"
        "number_of_replicas" => "0"
        "uuid" => "bcNRvVCzSBWgd0I84KIlGg"
        "version" => array:1 [▼
          "created" => "8020099"
        ]
      ]
    ]
  ]
]
CommandIndex.php:58
```

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.