-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Description
I was trying this example: https://github.com/zeromicro/zero-examples/tree/main/graceful/dns, but encountered dial error:
2025/09/19 15:13:27 rpc dial: dns:///gracefulrpc:3456, error: context deadline exceeded, make sure rpc service "gracefulrpc:3456" is already started
goroutine 1 [running]:
runtime/debug.Stack()
/opt/go/src/runtime/debug/stack.go:26 +0x5e
github.com/zeromicro/go-zero/core/logx.Must({0x1fb5840?, 0xc000511370?})
/home/bluven/go/pkg/mod/github.com/zeromicro/[email protected]/core/logx/logs.go:225 +0x4e
github.com/zeromicro/go-zero/zrpc.MustNewClient({{{0x0, 0x0, 0x0}, {0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, 0x0}, ...}, ...}, ...)
/home/bluven/go/pkg/mod/github.com/zeromicro/[email protected]/zrpc/client.go:45 +0x65
main.main()
/home/bluven/Workspace/go/zero-examples/graceful/dns/api/graceful.go:26 +0x15f
{"@timestamp":"2025-09-19T15:13:27.746+08:00","content":"rpc dial: dns:///gracefulrpc:3456, error: context deadline exceeded, make sure rpc service \"gracefulrpc:3456\" is already started\n\ngoroutine 1 [running]:\nruntime/debug.Stack()\n\t/opt/go/src/runtime/debug/stack.go:26 +0x5e\ngithub.com/zeromicro/go-zero/core/logx.Must({0x1fb5840?, 0xc000511370?})\n\t/home/bluven/go/pkg/mod/github.com/zeromicro/[email protected]/core/logx/logs.go:225 +0x4e\ngithub.com/zeromicro/go-zero/zrpc.MustNewClient({{{0x0, 0x0, 0x0}, {0x0, 0x0}, 0x0, {0x0, 0x0}, {0x0, 0x0}, ...}, ...}, ...)\n\t/home/bluven/go/pkg/mod/github.com/zeromicro/[email protected]/zrpc/client.go:45 +0x65\nmain.main()\n\t/home/bluven/Workspace/go/zero-examples/graceful/dns/api/graceful.go:26 +0x15f\n","level":"fatal"}
exit status 1
I have already put name gracefulrpc
in the /etc/hosts:
cat /etc/hosts
127.0.0.1 localhost gracefulrpc
127.0.1.1 bluven
but the dial error still occurs. I also tested with name dns:///localhost:3456
which worked:
➜ api git:(main) ✗ go run .
dns:///localhost:3456 # the result of c.BuildTarget()
{"@timestamp":"2025-09-19T15:27:07.092+08:00","caller":"p2c/p2c.go:181","content":"p2c - conn: 127.0.0.1:3456, load: 5602, reqs: 1","level":"stat"}
15:27:07 from host: bluven
{"@timestamp":"2025-09-19T15:27:07.093+08:00","caller":"handler/loghandler.go:147","content":"[HTTP] 200 - GET /api/graceful - 127.0.0.1:45866 - curl/8.5.0","duration":"31.6ms","level":"info","span":"334b0c588f993a32","trace":"c0933427d05b176ba5177f08c9cc3c41"}
I also tested gracefulrpc:3456 with nc command:
api git:(main) ✗ nc -zv gracefulrpc 3456
Connection to gracefulrpc (127.0.0.1) 3456 port [tcp/*] succeeded!
the api config is:
{
"Name": "graceful-api",
"Host": "0.0.0.0",
"Port": 8888,
"MaxConns": 1000000,
"Rpc": {
"Target": "dns:///localhost:3456"
}
}
In the origin config, the Target field is named Server which is wrong, so I changed it.
So, How should I do to make the example run successfully?
Metadata
Metadata
Assignees
Labels
No labels