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

r2dbc does not work with cloud run #509

Open
arscyper007 opened this issue Oct 4, 2023 · 0 comments
Open

r2dbc does not work with cloud run #509

arscyper007 opened this issue Oct 4, 2023 · 0 comments

Comments

@arscyper007
Copy link

arscyper007 commented Oct 4, 2023

Expected Behavior

based on this doc including the cloud-sql connector and setting gcp url as defined below should be working
have tried several variations and it does not connect.
R2DBC URL template: r2dbc:gcp:postgres://<DB_USER>:<DB_PASS>@<CLOUD_SQL_CONNECTION_NAME>/<DATABASE_NAME>

Also have played around with explicitly defining options etc through configuration but no success:
r2dbc:
datasources:
default:
dialect: POSTGRES
username: ${POSTGRES_USER:postgres}
password: ${POSTGRES_PASSWORD:postgres}
schema: postgres
schema-generate: none
url: ${POSTGRES_URL:r2dbc:postgresql://localhost:5433/gcdb}
db-type: postgres
ssl: ${POSTGRES_SSL_ENABLED:false}
options:
driver: pool
protocol: postgresql
acquireRetry: 60
maxSize: ${POSTGRES_POOL_SIZE:2}
minIdle: 1
initialSize: 1
maxIdleTime: PT60M
driver: ${POSTGRES_DRIVER:gcp}

Also tried:

@bean
@singleton
@nAmed("googleConnection")
public ConnectionFactory connectionFactory() {
ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
.option(DRIVER, "gcp")
.option(PROTOCOL, "postgresql")
.option(PASSWORD, "postgres")
.option(USER, "postgres")
.option(DATABASE, "postgres")
.option(HOST, "project:us-central1:db-instance")
.option(SSL, true)
.option(ENABLE_IAM_AUTH, true)

            .build();

    ConnectionFactory connectionFactory = ConnectionFactories.get(options);
    ConnectionPoolConfiguration poolConfiguration = ConnectionPoolConfiguration.builder(connectionFactory)
            .maxSize(10)
            .maxIdleTime(Duration.ofMinutes(30))
            .build();
    return new ConnectionPool(poolConfiguration);
}

Actual Behaviour

Cannot connect to project:us-central1:db-instance/:5432" it works perfectly fine using the jdbc url with jdbc driver for same container

Steps To Reproduce

No response

Environment Information

JDK17

Example Application

No response

Version

4.1.2

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