Skip to content

[core rpc] coro_rpc_client cannot reconnect to a different address #995

Closed

Description

@ykwd

Search before asking

  • I searched the issues and found no similar issues.

What happened + What you expected to happen

For coro_rpc_client:

  1. First call coro_rpc_client::connect() to address A.
  2. Then the server that listens to A crashes.
  3. Call coro_rpc_client::connect() to address B.
    If B and A are equal, then in step 3, the client can be reconnected to B.
    If B is different from A, then in step 3, the client tries to reconnect to A, even if the input address is B.

Reproduction way

The problem comes from the following code in https://github.com/alibaba/yalantinglibs/blob/main/include/ylt/coro_rpc/impl/coro_rpc_client.hpp

    if (config_.host.empty()) {
      config_.host = std::move(host);
    }
    if (config_.port.empty()) {
      config_.port = std::move(port);
    }

As there is no public interface to clear the config's host and port, once the client is connected to address A, it can no longer connect to a different address.

Anything else

I wonder if this is a bug or a feature, but in the following case, reconnecting to a different address is useful (in fact, this is how I find this bug/feature) :

Suppose there are multiple server instances, and the client connects to one server at the beginning. As time goes by, that server crashes, then the client has to find a live server and reconnect to it.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Activity

  1. poor-circle commented on Jun 27, 2025

    @poor-circle
    Collaborator

    Thanks for your report. I think it's a bug. I will fix it later.

  2. self-assigned this
    on Jun 27, 2025
  3. added
    bug
    on Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions