-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
ConnectivityStateManager Status notification problem #11615
Comments
From the Javadoc:
What do you hope the passed |
Understood. Our client uses a domain name to connect to the server, but the server IP may change, such as in the k8s environment. When reconnecting through the automatic reconnection mechanism, the IP cannot be resolved based on the domain name. We will manually rebuild the channel based on its status, but it seems that notifyWhenStateChanged cannot be used. Do you have any suggestions on your end? Thanks |
Why not? The client will re-resolve DNS when a connection is dropped/failed. So it will do the same as you're wanting to do. If there's only one IP, then a regular k8s service should be fine; you wouldn't benefit from a headless service.
You can learn about TRANSIENT_FAILURE... private void handleStateChange() {
ConnectivityState state = channel.getState(false);
if (state == TRANSIENT_FAILURE) {
// react
} else {
channel.notifyWhenStateChanged(state, this::handleStateChange);
}
}
channel.notifyWhenStateChanged(ConnectivityState.IDLE, this::handleStateChange); Not that I'd encourage doing that to tear down the channel. If you do that, at the very least double-check that the address has actually changed before throwing away the TRANSIENT_FAILURE channel. |
The text was updated successfully, but these errors were encountered: