我们只是将我们的第一个Neo4j 2.1应用程序安装到Jelastic服务器环境中,并且无法连接到db工作。简单程序(来自neo4jphp: Cannot instantiate abstract class 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] =>基本领域=" neo4j graphdb"
[Content-Type] =>为text / html;字符集= ISO-8859-1
[Cache-Control] =>必重新验证,无缓存,无店铺
[Content-Length] => 0
[服务器] =>码头(9.0.5.v20130815)
)
身体:阵列
(
)
'
我应该在Apache 2.2环境中的某处配置user_id /密码,还是缺少其他东西?
毕竟谢谢! 工作版是:
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()"如果您没有可信任的环境,应该使用。
答案 0 :(得分: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();