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

Cannot connect to the postgresql server X.X.X.X: could not send SSL negotiation packet #94

Open
dmlvc opened this issue Jan 11, 2022 · 1 comment

Comments

@dmlvc
Copy link

dmlvc commented Jan 11, 2022

Hi! Trying to establish connection with remote PG server got error "Warning: cannot connect to the postgresql server X.X.X.X: could not send SSL negotiation packet: Resource temporarily unavailable". Same result for "li run main.cc" and local CMake build. pgcli works fine with the same connection parameters.

    auto db = pgsql_database(
            s::host = "xxx.xxx.xxx.xxx", // Hostname or ip of the database server
            s::database = "my-services",  // Database name
            s::user = "admin", // Username
            s::password = "admin", // Password
            s::port = 31357, // Port
            s::charset = "utf8", // Charset
            // Only for async connection, specify the maximum number of SQL connections per thread.
            s::max_async_connections_per_thread = 200,
            // Only for synchronous connection, specify the maximum number of SQL connections
            s::max_sync_connections = 2000);

    auto countries_orm = sql_orm_schema(db, "sys.country")
            .fields(
                    s::id(s::auto_increment, s::primary_key) = int(),
                    s::code = std::string(),
                    s::code_3 = std::string(),
                    s::code_dig = std::string(),
                    s::name = std::string(),
                    s::name_engl = std::string(),
                    s::note = std::string()
            );

    auto countries = countries_orm.connect();
@QiMata
Copy link

QiMata commented Mar 13, 2022

Fought this for a while and still don't have a great answer. The error is from the libpq library however. If you put a delay in the pgstatus check loop, it works. Without the delay it has a packet issue whether ssl is involved or not.

Edit - This appears to be an issue if you immediately try to connect after an app starts. Start the app with a sleep and all connections work well. This is libpq as far as I can tell.

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