Spring Project Reactor: Reactive Netty DNS resolver issue

128 Views Asked by At

I've got an issue with reactive netty trying to resolve the DNS for an r2dbc DB connection. I use DatabaseClient which means the solutions for HttpClient I've seen in other questions won't be the right solution. And my application doesn't have any REST endpoints. The error I get is as below:

Caused by: io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'xxxx-xxx-rds-mysql.xxxx.eu-west-2.rds.amazonaws.com' [A(1)] and search domain query for configured domains failed as well: [tenant-xx-xxx.svc.cluster.local, svc.cluster.local, cluster.local, corp.xxx.xx.uk, eu-west-2.compute.internal]
    at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1120)
    ... 39 common frames omitted
Caused by: io.netty.resolver.dns.DnsErrorCauseException: Query failed with SERVFAIL
    at io.netty.resolver.dns.DnsResolveContext.onResponse(..)(Unknown Source)
"}
{"timestamp": "2024-02-26T10:57:34.781Z", "level": "ERROR", "traceId": "", "spanId": "", "class": "r.c.p.Operators", "message": "Operator called default onErrorDroppedreactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection
Caused by: org.springframework.dao.DataAccessResourceFailureException: Failed to obtain R2DBC Connection
    at org.springframework.r2dbc.connection.ConnectionFactoryUtils.lambda$getConnection$0(ConnectionFactoryUtils.java:100)

I use application.yml to configure the R2DBC connection and don't have any ConnectionFactory configuration class for this.

spring:
  r2dbc:
    pool:
      max-size: ${MAX_POOL_SIZE:10}
    url: ${DB_URL:r2dbc:mysql://xxx-core.xxx.eu-west-2.rds.amazonaws.com:3207/db?autoReconnect=true&useSSL=false&createDatabaseIfNotExist=true}
    username: ${USERNAME:core}
    password: ${PASSWORD:core}

Spring Boot version: 3.2.3
io.netty:netty-resolver-dns:4.1.107.Final
I also use this dependency from the Start.Spring.io website.

<dependency>
  <groupId>io.asyncer</groupId>
  <artifactId>r2dbc-mysql</artifactId>
  <version>1.0.6</version>
</dependency>

Update:
I have added this bean configuration and it still doesn't solve the issue!

@Configuration
public class ApplicationConfiguration {

    @Bean
    public HttpClient httpClient(){
        return HttpClient.create().resolver(DefaultAddressResolverGroup.INSTANCE);
    }
}

Please, any assistance would help. Thanks!

0

There are 0 best solutions below