stefanak-michal / pdo-bolt

PDO implementation of Bolt protocol
MIT License
2 stars 0 forks source link

Can't connect to a neo4j aura instance with pdo_bolt #4

Open Division70 opened 1 year ago

Division70 commented 1 year ago

Hello !

I'm trying to work with pdo_bolt connection with an neo4j aura instance.

Here's my code :

$pdo = new \pdo_bolt\PDO('bolt:host=1c27354c.databases.neo4j.io;port=7687;appname=pdo-bolt', 'neo4j', ''); $stmt = $pdo->prepare('MATCH (m:Movie) RETURN m.title AS title ORDER BY m.title ASC LIMIT $n'); $stmt->bindValue('n', 123, \PDO::PARAM_INT); $stmt->execute(); $stmt->setFetchMode(\PDO::FETCH_ASSOC); foreach ($stmt AS $row) { print_r($row); }

Connection is refused, if have an error from

[app/src/Bolt/Bolt.php:52] Bolt\connection\Socket->connect() [app/src/pdo_bolt/drivers/bolt/Driver.php:107] Bolt\Bolt->build() [app/src/pdo_bolt/PDO.php:68] pdo_bolt\drivers\bolt\Driver->__construct() [app/controllers/MainController.php:16] pdo_bolt\PDO->__construct() [lib/base.php:1955] MainController->render()

Thanks for your help.

Best.

C

stefanak-michal commented 1 year ago

Hi.

When you want to connect to aura you require SSL. You can enable it with $options in PDO constructor. You can read about it in readme https://github.com/stefanak-michal/pdo-bolt#pdo-constructor-available-options

So your line will look like this:

$pdo = new \pdo_bolt\PDO('bolt:host=1c27354c.databases.neo4j.io;port=7687;appname=pdo-bolt', 'neo4j', 'password', ['ssl' => ['verify_peer' => true]]);
Division70 commented 1 year ago

Hello !

Thanks for your reply. I still have an error to connect but, now, it runs StreamSocket->connect().

[app/src/Bolt/Bolt.php:52] Bolt\connection\StreamSocket->connect() [app/src/pdo_bolt/drivers/bolt/Driver.php:107] Bolt\Bolt->build() [app/src/pdo_bolt/PDO.php:68] pdo_bolt\drivers\bolt\Driver->__construct() [app/controllers/MainController.php:16] pdo_bolt\PDO->__construct()

I checked my php config (PHP 8.0). Sockets and open ssl are enabled as well as Registered Stream Socket Transports | tcp, udp, unix, udg, ssl, sslv3, tls, tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3

Maybe i've make a mistake on the format ?

Thanks for your help.

Best.

Christophe

stefanak-michal commented 1 year ago

Do you still get timeout error? More info will be nice.

You don't need ext-sockets if you use SSL, because StreamSocket use native php stream functions. Only openssl is required. Your list of available transports is okay, it should use TLS (i think).