elasticsearch 弹性云PHP连接错误:我没有找到任何具有HttpAsyncClient接口的HTTP库

u4dcyp6a  于 2023-03-01  发布在  ElasticSearch
关注(0)|答案(2)|浏览(119)
    • bounty将在7天后过期**。回答此问题可获得+100声望奖励。Hans Wassink希望引起更多人对此问题的关注:我在寻找一个非标准的答案,我是一个有才华的谷歌:D

当连接到弹性云我不断运行到这个奇怪的错误:
致命错误:未捕获弹性\传输\异常\无异步客户端异常:我没有找到任何具有HttpAsyncClient接口的HTTP库。请确保安装提供"php-http/async-client-implementation"的包。您也可以使用Elastic\Transport\Transport::setAsyncClient()设置特定的异步库
我已经尝试了互联网提供的一切设置http客户端, composer 狂饮等...但无济于事。我也测试了我们的一个现场服务器和错误也存在。

    • 我的密码**:
$httpClient = new GuzzleHttp\Client();
$client = ClientBuilder::create()
    ->setHttpClient($httpClient)
    ->setElasticCloudId('xxxxxxxxxxxxxxxxxxxx')
    ->setBasicAuthentication('xxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
    ->build();
    • composer **
{
"require": {
    "elasticsearch/elasticsearch": "^8.6",
    "php-http/async-client-implementation": "*",
    "guzzlehttp/guzzle": "^7.5"
},
"config": {
    "allow-plugins": {
        "php-http/discovery": true
    }
}

}

voase2hg

voase2hg1#

disclaimer: I'm not a php dev
但是根据文献记载
可以使用setAsync()函数在elasticsearch-php中启用HTTP异步

tct7dpnv

tct7dpnv2#

disclaimer: I'm not a php dev either
对于那些不是PSR-18 compliant的客户端库,您应该需要一个具体的异步适配器/实现,例如

"require": {
    "elasticsearch/elasticsearch": "^8.6",
    "php-http/async-client-implementation": "*",
    "guzzlehttp/guzzle": "^7.5",
    "php-http/guzzle7-adapter"            <----------
}

相关问题