[php-src] Issue #15637: Connection problems with postgres pdo using php 8.3.10 and 8.2.22
| From: | mathieu-pillar | Date: | Thu, 29 Aug 2024 13:58:02 +0000 |
| Subject: | [php-src] Issue #15637: Connection problems with postgres pdo using php 8.3.10 and 8.2.22 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247631@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/15637
Author: mathieu-pillar
### Description
The following code:
```php
// Database connection details
$host = '<ip of common database>';
$dbname = 'postgres';
$user = 'postgres';
$pass = '<password>';
try {
// Create a new PDO instance
$dsn = "pgsql:host=$host;dbname=$dbname";
$pdo = new PDO($dsn, $user, $pass);
// Set error mode to exception
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// SQL query
$sql = "SELECT * FROM topics LIMIT 20";
// Execute the query
$stmt = $pdo->query($sql);
// Fetch all results
$topics = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Display the results
foreach ($topics as $topic) {
echo "ID: " . $topic['id'] . " - Title: " .
$topic['display_name'] . "\n";
}
} catch (PDOException $e) {
// Handle connection error
echo "Connection failed: " . $e->getMessage();
throw $e;
}
// Close the connection
$pdo = null;
```
Resulted in this output:
```
My data from the table to be printed to the console
```
But I expected this output instead:
```
Connection failed: SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily
unavailablePHP Fatal error: Uncaught PDOException: SQLSTATE[08006] [7] could not send SSL
negotiation packet: Resource temporarily unavailable in /home/forge/test.php:12
Stack trace:
#0 /home/forge/test.php(12): PDO->__construct()
#1 {main}
thrown in /home/forge/test.php on line 12
Fatal error: Uncaught PDOException: SQLSTATE[08006] [7] could not send SSL negotiation packet:
Resource temporarily unavailable in /home/forge/test.php:12
Stack trace:
#0 /home/forge/test.php(12): PDO->__construct()
#1 {main}
thrown in /home/forge/test.php on line 12
```
## More context and tests
I have been working on setting up a production environment at work. We already had a staging server
in place. So I am mirroring my setup that I have in staging for my production. I am now facing a
wall trying to connect to a remote database other eth1 (private ip) between two Digital Ocean
droplets. It all seems to point to a php source error.
Here is a network diagram of my setup.

Flow C and D work fine regardless of php version installed. They use localhost as host. Using php
pdo.
Flow A and B use eth1 (private ip) on digital ocean to communicate between droplets inside the same
VPC using php pdo
Flow A works only using php 8.3.2 (which was installed a few months ago). I installed 8.2 today
which resolved to 8.2.22 and I get the exception mentioned above.
Flow B does not work with either 8.3.10 or 8.2.22
Also, I can connect to the common database using psql from both staging and production droplets
without issue.
### PHP Version
8.3.10, 8.2.22
### Operating System
Ubuntu 22.04, Ubuntu 24.04