[英]Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Unable to retrieve server info [401]:
I just installed neo4j server in Windows and am trying to connect with php. 我刚刚在Windows中安装了neo4j服务器,正在尝试与php连接。 I have xampp running, installed neo4jphp with composer, and then tried to check the connection using the following script:
我正在运行xampp,并使用composer安装了neo4jphp,然后尝试使用以下脚本检查连接:
<?php
require('vendor/autoload.php');
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());
?>
Now, instead of showing server status, a fatal error occured like this: 现在,没有显示服务器状态,而是发生了致命错误,如下所示:
Fatal error: Uncaught exception 'Everyman\\Neo4j\\Exception' with message 'Unable to retrieve server info [401]: Headers: Array ( [Date] => Wed, 27 May 2015 10:54:01 GMT [Content-Type] => application/json; charset=UTF-8 [WWW-Authenticate] => None [Content-Length] => 144 [Server] => Jetty(9.2.z-SNAPSHOT) ) Body: Array ( [errors] => Array ( [0] => Array ( [message] => No authorization header supplied. [code] => Neo.ClientError.Security.AuthorizationFailed ) ) ) ' in C:\\xampp\\htdocs\\neo4j\\vendor\\everyman\\neo4jphp\\lib\\Everyman\\Neo4j\\Command.php:116 Stack trace: #0 C:\\xampp\\htdocs\\neo4j\\vendor\\everyman\\neo4jphp\\lib\\Everyman\\Neo4j\\Command\\GetServerInfo.php(53): Everyman\\Neo4j\\Command->throwException('Unable to retri...', 401, Array, Array) #1 C:\\xampp\\htdocs\\neo4j\\vendor\\everyman\\neo4jphp\\lib\\Everyman\\Neo4j\\Command.php(69): Everyman\\Neo4j\\Command\\GetServerInfo->handleResult(401, Array, Array) #2 C:\\xa in C:\\xampp\\htdocs\\neo4j\\vendor\\everyman\\neo4jphp\\lib\\Everyman\\Neo4j\\Command.php on line 116
致命错误:消息为“无法检索服务器信息的未捕获异常'Everyman \\ Neo4j \\ Exception” [401]:标头:数组([Date] => Wed,27 May 2015 10:54:01 GMT [Content-Type] = > application / json; charset = UTF-8 [WWW-Authenticate] =>无[Content-Length] => 144 [Server] => Jetty(9.2.z-SNAPSHOT))正文:Array([errors] => Array ([0] =>数组([消息] =>未提供授权标头。[代码] => Neo.ClientError.Security.AuthorizationFailed)))'在C:\\ xampp \\ htdocs \\ neo4j \\ vendor \\ everyman \\ neo4jphp \\ lib \\ Everyman \\ Neo4j \\ Command.php:116堆栈跟踪:#0 C:\\ xampp \\ htdocs \\ neo4j \\ vendor \\ everyman \\ neo4jphp \\ lib \\ Everyman \\ Neo4j \\ Command \\ GetServerInfo.php(53):Everyman \\ Neo4j \\ Command-> throwException('无法检索...',401,Array,Array)#1 C:\\ xampp \\ htdocs \\ neo4j \\ vendor \\ everyman \\ neo4jphp \\ lib \\ Everyman \\ Neo4j \\ Command.php(69): Everyman \\ Neo4j \\ Command \\ GetServerInfo-> handleResult(401,Array,Array)#2 C:\\ xa in C:\\ xampp \\ htdocs \\ neo4j \\ vendor \\ everyman \\ neo4jphp \\ lib \\ Everyman \\ Neo4j \\ Command.php 116
How to solve this? 如何解决呢? Any help will be appreciated.
任何帮助将不胜感激。 Thanks in advance.
提前致谢。
If you've installed the newest version of Neo4j, you will need authorization (provide a username and password) to connect to Neo4j. 如果安装了最新版本的Neo4j,则需要授权(提供用户名和密码)才能连接到Neo4j。 Your Everyman bundle does not seem to have one, or you are using an older one.
您的Everyman捆绑包似乎没有捆绑包,或者您使用的是旧的捆绑包。 I'm using Neoxygen/neoclient myself, which does provide the ability to provide username and password.
我自己在使用Neoxygen / neoclient ,它确实提供了提供用户名和密码的功能。
It will work. 它会工作。 You just need to define the authorization credentials, for example like this:
您只需要定义授权凭证,例如:
<?php
require('vendor/autoload.php');
$client = new Everyman\Neo4j\Client(
(new Everyman\Neo4j\Transport\Curl('localhost',7474))
->setAuth('neo4j','neo4j')
);
print_r($client->getServerInfo());
Adjust the user/password accordingly('neo4j'/'neo4j' are default ones). 相应地调整用户名/密码(默认为“ neo4j” /“ neo4j”)。
Another solution is to disable the requirement for authorization when accessing Neo4j. 另一种解决方案是在访问Neo4j时禁用授权要求。 This can be done by editing Neo4j config file:
这可以通过编辑Neo4j配置文件来完成:
conf/neo4j-server.properties
and setting to false the following flag: 并将以下标志设置为false:
dbms.security.auth_enabled=false
Of course you need to remember about restarting the server afterwards. 当然,您需要记住有关之后重新启动服务器的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.