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

对Hertz做服务发现的注册时,启动Listen任意端口时,Transport最终使用的端口无法正确传给Registry #1062

Open
hgcncn opened this issue Feb 4, 2024 · 6 comments
Labels
question Further information is requested

Comments

@hgcncn
Copy link

hgcncn commented Feb 4, 2024

if err := opt.Registry.Register(opt.RegistryInfo); err != nil {

这里仅使用opt中的registry info,而kitex在启动后会更新registry info

对应现象是hertz能正常监听到任意端口,但在initOnRunHooks时,没有用监听到的端口地址去配置服务发现

2024/02/04 19:38:38.789411 main.go:31: [Info]  addr: :0
2024/02/04 19:38:38.789896 engine.go:389: [Info] HERTZ: Using network library=netpoll
2024/02/04 19:38:38.790097 transport.go:109: [Info] HERTZ: HTTP server listening on address=[::]:65094
2024/02/04 19:38:39.792078 hertz.go:133: [Error] HERTZ: Register error=parsing addr failed, err: invalid port 0
2024/02/04 19:38:39.795917 hertz.go:70: [Error] HERTZ: Receive close signal: error=parsing addr failed, err: invalid port 0

注册相关代码

	address, _ := net.ResolveTCPAddr("tcp", ":")
	blog.Infof("addr: %s", address.String())
	h := server.Default(
		server.WithHostPorts(address.String()),
		server.WithRegistry(r, &registry.Info{
			ServiceName: "demo.api.client",
			Addr:        address,
		}),
	)
@github-actions github-actions bot added the invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) label Feb 4, 2024
Copy link

github-actions bot commented Feb 4, 2024

This issue has been marked as invalid question, please give more information by following the issue template. The issue will be closed in 1 days if no further activity occurs.

@github-actions github-actions bot added the stale label Feb 4, 2024
@li-jin-gou li-jin-gou added question Further information is requested and removed invalid issue invalid issue (not related to Hertz or described in document or not enough information provided) stale labels Feb 4, 2024
@li-jin-gou
Copy link
Member

我们优化一下 cc @Skyenought

@li-jin-gou
Copy link
Member

快速解决方案是手动先指定一下 IP/Port 获取一下 loccal 的

@hgcncn
Copy link
Author

hgcncn commented Feb 4, 2024

快速解决方案是手动先指定一下 IP/Port 获取一下 loccal 的

已经按这个方式本地绕过~

@li-jin-gou
Copy link
Member

快速解决方案是手动先指定一下 IP/Port 获取一下 loccal 的

已经按这个方式本地绕过~

OK

@li-jin-gou
Copy link
Member

cc @ViolaPioggia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Development

No branches or pull requests

2 participants