baidu / baidu/starlight

BRPC 启动多个Server监听不同的端口,但是代理相同的endpoint类,会有什么问题

Open
#419 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
976
Forks
279
PR merge metrics
No merged PRs in 30d

Description

在生产环境使用Brpc服务,启动多个Server,监听不同端口,代理相同的endpoint。

public class EchoServiceImpl implements EchoService {
private static final Logger LOG = LoggerFactory.getLogger(EchoServiceImpl.class);

private String name;
public EchoServiceImpl(String name) {this.name = name;}
@Override
public Echo.EchoResponse echo(Echo.EchoRequest request) {
LOG.info("my name is " + name);
return response;
}
}

RpcServer rpcServer1 = new RpcServer(8000, RpcOptionsUtils.getRpcServerOptions());
rpcServer1.registerService(new EchoServiceImpl("a"));
rpcServer1.start();

RpcServer rpcServer2 = new RpcServer(8001, RpcOptionsUtils.getRpcServerOptions());
rpcServer2.registerService(new EchoServiceImpl("b"), RpcOptionsUtils.getRpcServerOptions());
rpcServer2.start();

请求的时候,无论请求哪个server的地址,发现永远是最后一次new 出来rpcEndpoint对象在处理,其他监听的端口没有任何作用,上面的输出永远是"my name is b"

加了github上的微信,但是一直没有通过,所以在这里请教下

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the example with two RpcServer instances on ports 8000 and 8001, registering EchoServiceImpl instances named "a" and "b". Start by tracing service registration and endpoint handling, then verify whether requests to each port reach the matching service instance. Done means the two listeners no longer route every request to the last-created endpoint.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.