impossibl / pgjdbc-ng

A new JDBC driver for PostgreSQL aimed at supporting the advanced features of JDBC and Postgres
https://impossibl.github.io/pgjdbc-ng
Other
596 stars 108 forks source link

Connect timeout with pgjdbc-ng but PostgreSQL JDBC Driver work #568

Closed AaaBin closed 2 years ago

AaaBin commented 2 years ago

I have an application with one connection from pgjdbc-ng(0.8.9) for asynchronous notification and others from PostgreSQL JDBC Driver(Spring Data JPA) for other tasks. Everything was fine in developing, but the connection from pgjdbc-ng got connect timeout when in SIT environment. It confused me because other connections work totally fine. I've tried two different code:

@Bean
public PGConnection getPGConnection() throws SQLException {
    var connectionString = String
        .format("jdbc:pgsql://%s/%s?ssl.mode=require", host, database);
    return DriverManager
            .getConnection(connectionString, user, password)
            .unwrap(PGConnection.class);
}

and

@Bean
public PGConnection getPGConnection() throws SQLException {
    var dataSource = new PGDataSource();
    dataSource.setUrl("jdbc:pgsql://host/dbname");
    dataSource.setUser(user);
    dataSource.setPassword(password);  
    dataSource.setSslMode(SSLMode.Require.name());
    return dataSource.getConnection().unwrap(PGConnection.class);
}

All these two got the same result, only the connections from PostgreSQL JDBC Driver works. Here is the error message:

Cause by: java.io.IOException: Timeout starting connection
    at com.impossibl.postgres.protocol.v30.ServerConnectionFactory.startup
    ...

Other info: running on: RHEL 8 postgresql version: 13 postgresql server force client connect with ssl(tls 1.3 only)

I'm sorry for lack of information. I can't reproduce it, these codes above are work in my enviroment.

Did I do something wrong? Please give me advice. Thank you.