Curl 在php Neo4j php客户端中设置Neo4j连接超时

Curl 在php Neo4j php客户端中设置Neo4j连接超时,curl,neo4j,graphaware,Curl,Neo4j,Graphaware,过去,我们使用以下代码连接neo: use GraphAware\Neo4j\Client\ClientBuilder; $neo4j = ClientBuilder::create() -> addConnection('default', $neo_ip) -> setDefaultTimeout($neo_timeout) -> build(); setDefaultTimeout已被弃用,默认

过去,我们使用以下代码连接neo:

use GraphAware\Neo4j\Client\ClientBuilder;
 $neo4j  = ClientBuilder::create()
            -> addConnection('default', $neo_ip)
            -> setDefaultTimeout($neo_timeout)
            -> build();
setDefaultTimeout
已被弃用,默认卷曲超时为5秒,对于某些查询来说不够长

我们可以使用螺栓代替,但是螺栓连接中的
setDefaultTimeout
也可能会被弃用

use GraphAware\Neo4j\Client\ClientBuilder;
$neo4j  = ClientBuilder::create()
           -> addConnection('bolt',    $neo_bolt_ip)
            -> setDefaultTimeout($neo_timeout)
            -> build();
设置http连接超时的新方法如下所示:

use GraphAware\Neo4j\Client\ClientBuilder;
use Http\Client\Curl\Client;
$options = [
        CURLOPT_CONNECTTIMEOUT => 99, // The number of seconds to wait while trying to connect.
        CURLOPT_SSL_VERIFYPEER => false   // Stop cURL from verifying the peer's certificate
    ];
    $httpClient = new Client(null, null, $options);
    $config = \GraphAware\Neo4j\Client\HttpDriver\Configuration::create($httpClient);

    $neo4j  = ClientBuilder::create()
            -> addConnection('default', $neo_ip, $config)
            -> build();
然而,使用这种新方法,我得到了一个
不受支持的媒体类型
异常。

如果有人对此有所了解,请分享

现在,我们可以使用以下设置超时:

$neo_timeout = 999;
$neo_ip = "http://user:passwd@127.0.0.1:7474";
use GraphAware\Neo4j\Client\ClientBuilder;
$httpClient = \Http\Adapter\Guzzle6\Client::createWithConfig(['timeout'=>$neo_timeout]);
$config = \GraphAware\Neo4j\Client\HttpDriver\Configuration::create($httpClient);

$neo4j  = ClientBuilder::create()
        -> addConnection('default', $neo_ip, $config)
        -> build();
已经发布了使用php http/curl客户端的修复程序
请参阅:

请参阅