0

I have read the instructions at both https://github.com/graphaware/neo4j-php-client#installation-and-basic-usage and https://docs.graphenedb.com/docs/php

While this example from the GrapheneDb docs does work, it does not use GraphAware Neo4j PHP Client, it uses Neo4j Bolt PHP:

// Example for Bolt
$config = \GraphAware\Bolt\Configuration::newInstance()
->withCredentials('user', 'pass')
->withTimeout(10)
->withTLSMode(\GraphAware\Bolt\Configuration::TLSMODE_REQUIRED);

$driver = \GraphAware\Bolt\GraphDatabase::driver('bolt://hobby-my-graph-db.dbs.graphenedb.com:24786', $config);
$client = $driver->session();

I can't find a working example anywhere, I have tried all kinds of things; I have double and triple checked the connection strings, I have tried http as well as bolt, I have logged into the database from neo4j browser so I know the credentials must be ok.

This is what my code looks like:

/* GraphAware\Bolt\Configuration */
$config = Configuration::create()
->withCredentials('user', 'pass')
->withTimeout(10)
->withTLSMode(Configuration::TLSMODE_REQUIRED);    
        
/* GraphAware\Neo4j\Client\ClientBuilder */
$client = ClientBuilder::create()
->addConnection('bolt', 'bolt://hobby-my-graph-db.dbs.graphenedb.com:24787', $config)
->build();
    
$result = $client->run("CREATE (n:Person {name: 'Bob'}) RETURN id(n)");

When I try to run the query I get:

Exception 'GraphAware\Bolt\Exception\HandshakeException' with message 'Error receiving data'
in /path-to-project/vendor/graphaware/neo4j-bolt/src/Driver.php:165

Does anyone have a complete working connection example to GrapheneDb using graphaware/neo4j-php-client?

dataskills
  • 646
  • 7
  • 15

2 Answers2

0

The bolt driver: For some reason GraphAware\Neo4j\Client\Connection\Connection.php does not use the configuration you pass in to the GraphAware\Neo4j\Client\ClientBuilder->addConnection() method (???). It rebuilds the configuration, leaving out everything except for the username and password. So, if your connection requires TLS mode like mine, it will never work without altering the source.

At GraphAware\Neo4j\Client\Connection\Connection.php:180 inside the buildDriver() method I simply use the configuration I passed in which is $this->config instead of the one they rebuild for you. Works as it should.

After alteration it looks like: $this->driver = BoltGraphDB::driver($uri, $this->config);

(graphaware/neo4j-php-client 4.8.5)

dataskills
  • 646
  • 7
  • 15
0

Actually, just don't use graphenedb, it sucks. Just use https://neo4j.com/cloud/aura. Works without any screwing around.

dataskills
  • 646
  • 7
  • 15