'Client is not supported for custom options
I am trying to use ClientBuilder of Elasticsearch using symfony 6. I am getting following error
The HTTP client Symfony\Component\HttpClient\Psr18Client is not supported for custom options
This is the code I have tried. I had same lines of code in laravel which worked.
$hosts = ['https://localhost:9200'];
$client = ClientBuilder::create()
->setHosts($hosts)
->setSSLVerification(false)
->setBasicAuthentication('elastic', 'password')
->build();
Solution 1:[1]
Just ran into the same issue in a Laravel 9 app (along with some other bugs in the package).
Be sure to set the client manually, otherwise it uses \Http\Discovery\Psr18ClientDiscovery to find the first class that extends the required interface \Psr\Http\Client\ClientInterface. Which in our case is Symfony\Component\HttpClient\Psr18Client, which is not yet supported (see https://github.com/elastic/elasticsearch-php/issues/990).
$hosts = ['https://localhost:9200'];
$client = ClientBuilder::create()
->setHttpClient(new \GuzzleHttp\Client)
->setHosts($hosts)
->setSSLVerification(false)
->setBasicAuthentication('elastic', 'password')
->build();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
