过去我们使用以下代码连接到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();
然而,使用这种新方法,我得到Unsupported Media Type
例外
如果有人对此有所了解,请分享。
答案 0 :(得分:0)
现在我们可以使用以下设置超时:
$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-client的修复方法
见:https://github.com/graphaware/neo4j-php-client/pull/114