我遵循了这个related question中的步骤,但是这个错误出现在我身上,你能帮忙吗?
HttpException中的HttpRequestEventSubscriber.php第74行:连接上的错误“默认”和消息"cURL错误7:未能连接到本地主机端口7474:连接被拒绝(参见http://curl.haxx.se/libcurl/c/libcurl-errors.html)“
这是我的.env代码
`APP_ENV=local
APP_DEBUG=true
APP_KEY=ChTIcRHTSR35M6rP0jwmOmhMNLuFpMVe
NEO4J_HOST=localhost
NEO4J_PORT=7474
NEO4J_USER=neo4j
NEO4J_PASSWORD=admin
NEO4J_TIMEOUT=300
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
`这是NeoClientServiceProvider代码
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Neoxygen\NeoClient\ClientBuilder;
class NeoClientServiceProvider extends ServiceProvider
{
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('neoclient', function ($app) {
return ClientBuilder::create()
->addConnection('default', 'http', env('NEO4J_HOST'), intval(env('NEO4J_PORT')), true, env('NEO4J_USER'), env('NEO4J_PASSWORD'))
->setDefaultTimeout( intval(env('NEO4J_TIMEOUT')) )
->setAutoFormatResponse(true)
->build();
});
}
}这是提供者
App\Providers\NeoClientServiceProvider::class,别名
'NeoClient' => App\NeoClient::class这是NeoClient类代码
<?php namespace App;
use Illuminate\Support\Facades\Facade;
class NeoClient extends Facade
{
protected static function getFacadeAccessor() { return 'neoclient'; }
}我的测试控制器
<?php
namespace App\Http\Controllers;
use App\NeoClient;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class test extends Controller
{
public function index()
{
$data = NeoClient::sendCypherQuery('CREATE (user:User {name:"Kenneth"}) RETURN user');
}
}当我在函数addConnection中为它做转储时,它在ClientBuilder类中
public function addConnection($alias, $scheme, $host, $port, $authMode = false, $authUser = null, $authPassword = null)
{
$this->configuration['connections'][$alias] = array(
'scheme' => $scheme,
'host' => $host,
'port' => $port,
'auth' => $authMode,
'user' => $authUser,
'password' => $authPassword,
);
dd($this);
return $this;
}

发布于 2015-09-07 22:35:52
好的。我安装了“家园”来重现你的环境。正如评论中所述,这本应是一个大问题。我设法使您与neo4j的连接正常工作:
ssh vagrant@127.0.0.1 -p 2222
vagrant@homestead:~$ ip route show default via 10.0.2.2 dev eth0 10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.10
这里的主机网关是10.0.2.2。
$ curl --user neo4j:admin "http://10.0.2.2:7474/db/data/" "extensions" : { }, "node" : "http://10.0.2.2:7474/db/data/node", "node_index" : "http://10.0.2.2:7474/db/data/index/node", "relationship_index" : "http://10.0.2.2:7474/db/data/index/relationship", "extensions_info" : "http://10.0.2.2:7474/db/data/ext", "relationship_types" : "http://10.0.2.2:7474/db/data/relationship/types", "batch" : "http://10.0.2.2:7474/db/data/batch", "cypher" : "http://10.0.2.2:7474/db/data/cypher", "indexes" : "http://10.0.2.2:7474/db/data/schema/index", "constraints" : "http://10.0.2.2:7474/db/data/schema/constraint", "transaction" : "http://10.0.2.2:7474/db/data/transaction", "node_labels" : "http://10.0.2.2:7474/db/data/labels", "neo4j_version" : "3.0.0-alpha.163"
https://stackoverflow.com/questions/32444507
复制相似问题