![](/img/trans.png)
[英]Golang TCP server gives “dial tcp 127.0.0.1:9999: connect: connection refused” error
[英]"transport: Error while dialing dial tcp 127.0.0.1:9001: connect: connection refused"
在 golang 中,我正在嘗試實現 GRPC,但出現此錯誤。 其他一切看起來都很好。
這是代碼片段。
type EventServiceClient struct {
Client proto.EventServiceClient
Conn *grpc.ClientConn
}
func InitEventServiceClient(addr int) (msc EventServiceClient, err error) {
conn, err := grpc.Dial("localhost:9001", grpc.WithInsecure())
if err != nil {
return
}
client := proto.NewEventServiceClient(conn)
msc = EventServiceClient{
Conn: conn,
Client: client,
}
return
}
錯誤-
rpc 錯誤:代碼 = 不可用 desc = 連接錯誤:desc =“傳輸:撥打撥號 tcp 127.0.0.1:9001 時出錯:連接:連接被拒絕”
本地主機可能是 ip6 (::1) - 對於所有 ip 嘗試 127.0.0.1:9001 或 0.0.0.0:9001
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.