0

我们只是将我们的第一个 Neo4j 2.1 应用程序安装到 Jelastic 服务器环境中,并且无法连接到工作的数据库。简单的程序(来自neo4jphp 中的答案:无法实例化抽象类 Everyman\Neo4j\Transport)是这样的:

require('vendor/autoload.php');

use Everyman\Neo4j\Client;
$client = new Client($Server_ip_address, 8080);
print_r($client->getServerInfo()); 

最后一行给出错误 401 Unauthorized:

'无法检索服务器信息 [401]:\nHeaders: Array
(
[WWW-Authenticate] => Basic realm="neo4j graphdb"
[Content-Type] => text/html; charset=ISO-8859-1
[Cache- Control] => must-revalidate,no-cache,no-store
[Content-Length] => 0
[Server] => Jetty(9.0.5.v20130815)
)正文
:Array
(
)
'。

我应该在我的 Apache 2.2 环境中的某处配置 user_id/password,还是缺少其他东西?

毕竟谢谢!工作版本是这样的:

require('vendor/autoload.php');   
use Everyman\Neo4j\Client;
$client = new Everyman\Neo4j\Client($host, $port);
$client->getTransport()
  ->setAuth($username, $password);
print_r($client->getServerInfo());

如果您没有受信任的环境,也应该使用“->useHttps()”。

4

1 回答 1

1

如果您使用身份验证,则需要传递用户名/密码,如https://github.com/jadell/neo4jphp/wiki/Getting-started#testing-your-connection中的示例所示

require('vendor/autoload.php');

use Everyman\Neo4j\Client;
$client = new Client($Server_ip_address, 8080);
$client->setAuth($username, $password);
print_r($client->getServerInfo());

此外,如果您使用 HTTPS(如果您使用身份验证,建议使用),您还应该执行以下操作:

$client->useHttps();
于 2015-02-12T15:51:02.047 回答