繁体   English   中英

将Neo4j服务器与Neo4jPHP连接得到401

[英]Connecting Neo4j server with Neo4jPHP gives 401

我们只是将第一个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未经授权:

'无法检索服务器信息[401]:\\ nHeaders:Array

[WWW-Authenticate] =>基本领域=“ neo4j graphdb”
[Content-Type] => text / html; 字符集= ISO-8859-1
[Cache-Control] =>必须重新验证,无缓存,无存储
[内容长度] => 0
[服务器] =>码头(9.0.5.v20130815)

主体:阵列


”。

我应该在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()”。

如果您使用的是身份验证,则需要传递用户名/密码,如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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM