-
Notifications
You must be signed in to change notification settings - Fork 646
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
Some request of a webclient instance does not resolve the ip address of hostname correct after it has changed by the dns #3402
Comments
@stefan-g When the IP is changed you need to dispose the current connection pool, because it holds open connections to the old IP. You can do it with https://projectreactor.io/docs/netty/release/api/reactor/netty/resources/ConnectionProvider.html#disposeWhen-java.net.SocketAddress- |
@violetagg Thanks for your answer. If i configure maxIdleTime and maxLifeTime of the ConnectionProvider to a shorter time should the open connections be closed? |
@stefan-g yes they will |
Would it not make sense that the connection pool checks if the ip address of a domain name has changed when the connection is acquired? Could be a configurable feature |
@stefan-g We can think about some configuration but this has to be tightly coupled with DNS resolution configuration. Example let's say there is no expiration of the DNS cache but we check every time whether the IP is changed. Wdyt? |
@violetagg i think that would make sense because if ttl of the networkaddress cache is too high InetAddress would also not get the new ip address. The use case i have is as follow: |
@stefan-g Let me mark this as an enhancement. If you would like to provide a PR for this feature, it would be great! |
Probably not familiar enough with netty connection pool to provide a useful pr |
The web client instance connects (sometimes) to the old ip address of a domain name after the ip of the domain has changed by the dns. It looks like that the dns cache is not refreshed in all socket connections as it should. Only a restart of the service solves the problem.
Expected Behavior
When a ip address of a domain name changes, the ip of all socket addresses should be refreshed after the configured ttl time.
Actual Behavior
In some request the webclient connects to the old ip adress after it has changed by the dns server.
Steps to Reproduce
I can't reproduce it locally.
WebClient instance is cached in a spring service object and defined like that:
network address cache is set at application startup like that:
To monitor the ip-address i have defined a scheduler job that checks every hour (by calling InetAddress.getByName("https://MyHostname")) if the ip of the hostname has changed. InetAddress.getByName returns the correct ip address when it has changed. It looks to me that the wrong ip is not cached by InetAddress.
Possible Solution
?
Your Environment
Java 17 openjdk
Spring boot dependencies 3.2.8
Reactor-netty-core 1.1.21
Netty 4.1.111.Final
Linux os
The text was updated successfully, but these errors were encountered: