Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triple协议如何能够配置随机端口呢?同一台机器部署多个相同服务,端口会重复,java中协议端口可以允许-1端口随机分配 #2382

Closed
tiandi0716 opened this issue Aug 14, 2023 · 7 comments · Fixed by #2384

Comments

@tiandi0716
Copy link

tiandi0716 commented Aug 14, 2023

image

调整代码

image

不要默认值是不是才能通过后面逻辑?,否则后面判断端口逻辑是无效的?

image

@justxuewei
Copy link
Member

Thank you for reporting this. Firstly, the documentation you referenced is from Dubbo, not Dubbo-go. Therefore, the default port is not the same as the Dubbo's. Then, the condition of using ramdon port doesn't have problem, since the port should be specified to -1, instead of leaving empty.

@tiandi0716
Copy link
Author

@justxuewei Thank you your reply, But use "-1" in port field of string type, the length size is greater than 0, if i keep empty the field default is "20000",

image

there you are set the "default" tag value "20000", please give a simple of how to use random port?

thank you very much

@justxuewei
Copy link
Member

justxuewei commented Aug 15, 2023

use "-1" in port field of string type, the length size is greater than 0

What is happend while the length size is greater than 0? Does it not work while setting the port to -1?

image

Could you give me a link to this line of code? Instead of a picture. I'll take a look at this.

@tiandi0716
Copy link
Author

Protocol Init method

https://github.com/apache/dubbo-go/blob/main/config/protocol_config.go
image

https://github.com/creasty/defaults/blob/master/defaults.go
image

the code you are parse "default" tag, Port default "20000"
https://github.com/apache/dubbo-go/blob/main/config/protocol_config.go
image

my dubbogo.yaml config

dubbo:
  application: 
    name: go.micro.api.gateway
  registries:
    nacos:
      protocol: nacos
      address: 192.168.1.236:8848
  protocols:
    triple:
      name: tri
      port:  -1

justxuewei added a commit to justxuewei/dubbo-go that referenced this issue Aug 15, 2023
The condition of assigning a random port for protocols should be that port
is less than or equal to 0, not the length of the port string.

Fixes: apache#2382

Signed-off-by: Xuewei Niu <[email protected]>
@justxuewei
Copy link
Member

Thanks for report this issue. I've pushed a patch to fix the issue: #2384. Please let me know if you have any questions.

@tiandi0716
Copy link
Author

tiandi0716 commented Aug 15, 2023

Ok, thank you, i will let you know if i meet any question in use.

chickenlj pushed a commit that referenced this issue Aug 16, 2023
Fixes #2382. The condition of assigning a random port for protocols should be that port
is less than or equal to 0, not the length of the port string.
@project-snail
Copy link

Thanks for report this issue. I've pushed a patch to fix the issue: #2384. Please let me know if you have any questions.

感觉是判断-1才特殊处理?现在无法解析就随机分配 无法解析结束进程panic感觉比较合理

maguowei added a commit to maguowei/dubbo-go that referenced this issue Sep 27, 2023
maguowei added a commit to maguowei/dubbo-go that referenced this issue Sep 28, 2023
maguowei added a commit to maguowei/dubbo-go that referenced this issue Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants