Comments (4)
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:
- RFC 1123: "Requirements for Internet Hosts - Application and Support" - https://www.ietf.org/rfc/rfc1123.txt
- RFC 952: "DOD Internet Host Table Specification" - https://www.ietf.org/rfc/rfc952.txt
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.
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.
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.
Thank you so much for such a detailed answer, it helped me. I wish you success!!!
from r2dbc-mysql.
Related Issues (20)
- [Feature] Support for Lightweight Ping Syntax
- [feature] Compression protocol support
- [QUESTION] How about removing `socketTimeout`? HOT 1
- [feature] Refactor SQL statement parsing
- [feature] Add support for decoding session state info in Ok packets
- Add support for MariaDB connection redirection
- [feature] Support for Custom Loop Resources
- [feature] Support standard option `lockWaitTimeout` and `statementTimeout` HOT 1
- [feature]Enable Leak detection in CI pipeline HOT 2
- [bug]align with`RowMetaData#getColumnMetadata(String)` specification HOT 3
- [feature] Support for Stored Procedure Execution HOT 1
- [bug] Deploy broken HOT 3
- [bug]Fix Snapshot deployment
- [feature] Extract public API into API package
- Support for MariaDB Extend Type Info
- [feature] Support sql mode `NO_BACKSLASH_ESCAPES`
- [Release]v1.1.3 HOT 3
- [QUESTION] How could I set column definition's binary mode HOT 1
- [bug] Connection unexpectedly closed HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from r2dbc-mysql.