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

PDO Connection Issue with PostgreSQL #15

Open
umarhadi opened this issue Jul 20, 2024 · 0 comments
Open

PDO Connection Issue with PostgreSQL #15

umarhadi opened this issue Jul 20, 2024 · 0 comments

Comments

@umarhadi
Copy link

Description:

At the startup, the connection to the database works fine for the first request. However, after the first request, I start to get the following error:

SQLSTATE[08006] [7] could not send SSL negotiation packet: Resource temporarily unavailable (Connection: pgsql, SQL: (select * from ........)

Environment:

  • Laravel 9.52.15
  • PHP 8.2
  • PostgreSQL 15.6

Findings:

I tracked down the problem and discovered that PDO is not actually opening a connection to PostgreSQL. When using PDO, the error above occurs. However, when using pg_connect, the connection can be established and queries can be executed. Here are my findings:

  • Cannot open a connection using PDO.
  • I can open a connection using pg_connect (fly proxy).
  • I can open a connection from a database manager application.
  • The issue occurs in both development and production environments.

Attempts to Fix:

I changed sslmode in database.php from prefer to disable. For a short period, the connection was established, and queries could be executed. However, shortly after, I encountered a connection reset by peer error (from PostgreSQL log) and in the application log:

SQLSTATE[08006] [7] could not send startup packet: Resource temporarily unavailable (Connection: pgsql, SQL: (select * from ........)

I rolled back my deployment to December 2023 and checked the installed PHP extension versions. I found that the new deployment was using php8.2-swoole version 5.1.3, while the December 2023 deployment was using version 5.1.1. After comparing the commits between Swoole versions 5.1.1 and 5.1.3, I noticed several changes related to SSL, and I decided not to delve further into the details.

Temporary Solution:

To fix this issue, I forked this repository, removed the php8.2-swoole package, and built my own Docker image. I do not use PHP Swoole in my application.

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

1 participant