Code Monkey home page Code Monkey logo

Comments (4)

mirromutth avatar mirromutth commented on July 18, 2024 1

Sorry, I overlooked an important factor.

The hostname in the docker-compose.yaml file contains underscores, and r2dbc-spi cannot parse it correctly because java.net.URI cannot process it correctly. See also https://stackoverflow.com/questions/28568188 .

This causes DNS to resolve host "mysql_db:3306" instead of "mysql_db", so the resolution always fails.

Except for the first time, all my attempts were to write the docker-compose.yaml files myself, thus using hostnames without underscores, causing all my previous replies to be incorrect.

Strictly speaking, hostnames cannot contain underscores, so it's hard to tell whether this is intentional or not.

See:

K8s service names also do not allow underscores: https://stackoverflow.com/questions/77514907

See also r2dbc/r2dbc-spi#280 , ConnectionUrlParser

Parsing Code
import io.r2dbc.spi.ConnectionFactoryOptions;

public class ParsingMain {

    public static void main(String[] args) {
        ConnectionFactoryOptions o1 = ConnectionFactoryOptions.parse("r2dbc:mysql://underscore_db:3306");

        System.out.println(o1.getRequiredValue(ConnectionFactoryOptions.HOST));
        System.out.println(o1.getValue(ConnectionFactoryOptions.PORT));

        ConnectionFactoryOptions o2 = ConnectionFactoryOptions.parse("r2dbc:mysql://std-db:3306");

        System.out.println(o2.getRequiredValue(ConnectionFactoryOptions.HOST));
        System.out.println(o2.getValue(ConnectionFactoryOptions.PORT));

        URI u1 = URI.create("r2dbc://underscore_db:3306"); // ConnectionFactoryOptions.parse rewrites the URI

        System.out.println(u1.getHost()); // null
        System.out.println(u1.getPort()); // -1

        URI u2 = URI.create("r2dbc://std-db:3306");

        System.out.println(u2.getHost()); // std-db
        System.out.println(u2.getPort()); // 3306
    }
}

from r2dbc-mysql.

mirromutth avatar mirromutth commented on July 18, 2024

Seems to be caused by reactor-netty:1.1.9 on reactor-bom:2022.0.9. I had the same error and then when I tried upgrading it to reactor-bom:2022.0.16 this error gone. But I haven't seen any reports of this in reactor-netty or netty, more investigation is needed.

In addition, we should use reactor-netty-core instead of reactor-netty to slim dependencies. reactor-netty contains reactor-netty-http and reactor-netty-incubator-quic, which are not what we need.

It has been reproduced on Windows 11 and docker with eclipse-temurin:17-jdk-alpine image


2024-03-05: It cannot be reproduced on macOS 14.2.1 and docker 25.0.3 with eclipse-temurin:17-jdk image.

from r2dbc-mysql.

mirromutth avatar mirromutth commented on July 18, 2024

Would you mind letting me know what operating system, docker version, java image version in Dockerfile, and spring-data-r2dbc version you are using?


2024-03-06: Now it can be reproduced, a very inconspicuous configuration

from r2dbc-mysql.

Maxim1-1 avatar Maxim1-1 commented on July 18, 2024

Thank you so much for such a detailed answer, it helped me. I wish you success!!!

from r2dbc-mysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.