Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Division70 opened this issue May 1, 2023 · 3 comments
Open

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

Division70 opened this issue May 1, 2023 · 3 comments

Comments

@Division70
Copy link

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants