Skip to content

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

@ykwd

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!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions