2

我已经按照文档通过这个简单的步骤成功地使用了带有graphenedb的neo4jphp库(考虑到graphenedb不需要https)

require('vendor/autoload.php'); // or your custom autoloader
// Connecting to a different port or host
$client = new Everyman\Neo4j\Client(url, port);
// Connecting using HTTP and Basic Auth
$client->getTransport()
->setAuth('username', 'password');
// Test connection to server
print_r($client->getServerInfo());

但是,当尝试连接到一个graphstory实例时(当然,如果我从浏览器调用rest api,它们都可以正常工作,neo4j控制台工作正常等等)需要https如下

require('vendor/autoload.php'); // or your custom autoloader
// Connecting to a different port or host
$client = new Everyman\Neo4j\Client(url, port);
// Connecting using HTTPS and Basic Auth
$client->getTransport()
->useHttps()
->setAuth('username', 'password');
// Test connection to server
print_r($client->getServerInfo());

我收到以下错误。它们应该是相同的,我不明白为什么。

Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Can't open connection to https://neo-54f500bf2cc7e-364459c455.do-stories.graphstory.com:7473/db/data/' in /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport/Curl.php:91 
Stack trace: 
#0 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport.php(95): Everyman\Neo4j\Transport\Curl->makeRequest('GET', '/', NULL) 
#1 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Command.php(64): Everyman\Neo4j\Transport->get('/', NULL) 
#2 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Client.php(828): Everyman\Neo4j\Command->execute() 
#3 /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Client.php(464): Everyman\Neo4j\Client->runCommand(Object(Everyman\Neo4j\Command\GetServerInfo)) 
#4 /Applications/XAMPP/xamppfiles/htdocs/graphene/story.php(20): Every in /Applications/XAMPP/xamppfiles/htdocs/graphene/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport/Curl.php on line 91
4

2 回答 2

1

在我看来,neo4jphp 没有在 cURL 请求中配置 TLS 部分。

我通过从http://curl.haxx.se/docs/caextract.html (ca_bundle.crt) 下载证书包并将以下行添加到 Everyman\Neo4j\Transport\Curl.php 函数 makeRequest 来修复它:

$options[CURLOPT_CAINFO] = "your/path/to/ca-bundle.crt";

我为此在 GitHub 上创建了一个问题:https ://github.com/jadell/neo4jphp/issues/171

于 2015-05-18T06:40:30.163 回答
0

我是 Graph Story 的 CTO/Lead Dev。很抱歉听到您遇到麻烦。实际上,我刚刚查看了您的实例,从服务器端看起来一切正常。

如果没有其他信息,很难说您的示例连接代码是否存在问题。考虑到您过去曾使用同一个库连接到 GrapheneDB,我认为示例代码中出错的可能性很低。

根据您的实例的当前状态和 Neo4jPHP 抛出的异常,我猜测端口 7473 可能在您的网络上被阻止。您可以通过本地技术支持或切换到您知道端口 7473 已打开的网络并尝试再次连接来确认这一点。

于 2015-03-06T12:14:30.947 回答