Reputation: 366
I followed steps in this related question but this error appeared to me, Can you help please?
HttpException in HttpRequestEventSubscriber.php line 74: Error on Connection "default" with message "cURL error 7: Failed to connect to localhost port 7474: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)"
this is my .env code
`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
`
this is NeoClientServiceProvider code
<?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();
});
}
}
this is provider
App\Providers\NeoClientServiceProvider::class,
aliases
'NeoClient' => App\NeoClient::class
this is NeoClient class code
<?php namespace App;
use Illuminate\Support\Facades\Facade;
class NeoClient extends Facade
{
protected static function getFacadeAccessor() { return 'neoclient'; }
}
my test controller
<?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');
}
}
when I made dump for this in function addConnection which is in ClientBuilder class
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;
}
Upvotes: 3
Views: 1269
Reputation: 20185
Ok. I installed Homestead to reproduce your environment. As told in the comments this should have been a host issue. I managed to make your connection to neo4j working :
ssh [email protected] -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
Here the host gateway is 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"
Upvotes: 3