Open javeme opened 3 years ago
@javeme You can use new ServerConfig().setAdaptivePort(true);
and invoke serverConfig.getPort()
after the server started.
@ujjboy Thank you for your reply.
I tried setAdaptivePort(true)
after got your reply, but when multiple jobs(like YARN container) were started at the same time, they may still compete for the same port, resulting in a race error "Address already in use".
In this scenario, it would be a perfect solution if sofa-rpc can support random port.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@ujjboy There is still race condition with setAdaptivePort(true)
: "Address already in use", could you please take a look?
https://github.com/sofastack/sofa-rpc/blob/10dc5859283c1a06b2cbacf53e6f564abb488af9/core/api/src/main/java/com/alipay/sofa/rpc/common/utils/NetUtils.java#L99
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug
A clear and concise description of what the bug is.
Expected behavior
Expect to add port() method to
com.alipay.sofa.rpc.server.Server
interface, we can get the actual port from server implementation.Actual behavior
ServerConfig.getPort()
returns 0Steps to reproduce
Environment