sofastack / sofa-rpc

SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework.
https://www.sofastack.tech/sofa-rpc/docs/Home
Apache License 2.0
3.81k stars 1.17k forks source link

sofa端口自适应,预期不一致 #1313

Closed ZhengweiHou closed 1 year ago

ZhengweiHou commented 1 year ago

Your question

同一台机器启动两个sofa进程,开启端口自适应(AdaptivePort),但是两个进程服务注册端口一致,但实际生效端口不一致。通过验证端口自适应逻辑发现我的机器上ServerSocket.bind()预期结果不一致。详细情况如图所示: 图片

Your scenes

describe your use scenes (why need this feature)

Your advice

describe the advice or solution you'd like 这个问题也许是jvm的bug,但是应用有办法屏蔽这个问题吗?

Environment

OrezzerO commented 1 year ago

AdaptivePort 的逻辑在com.alipay.sofa.rpc.server.ServerFactory#resolveServerConfig , 可以看下这块代码. 和你理解的应该不太一样.

stale[bot] commented 1 year ago

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.

ZhengweiHou commented 9 months ago

图片 @OrezzerO 原图的示例就是com.alipay.sofa.rpc.server.ServerFactory#resolveServerConfig 中调用的 NetUtils获取可用端口的逻辑。测试时发生NetUtils通过ServerSocket.bind验证通过的端口却和实际sofa服务启动时生效的端口不一致,简化情景如原始截图发生的情景