Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go &引用;传输:拨号tcp 127.0.0.1:9001时出错:连接:连接被拒绝;_Go_Grpc - Fatal编程技术网

Go &引用;传输:拨号tcp 127.0.0.1:9001时出错:连接:连接被拒绝;

Go &引用;传输:拨号tcp 127.0.0.1:9001时出错:连接:连接被拒绝;,go,grpc,Go,Grpc,在golang,我试图实现GRPC,但出现了这个错误。其他一切看起来都很好 下面是代码片段 type EventServiceClient struct { Client proto.EventServiceClient Conn *grpc.ClientConn } func InitEventServiceClient(addr int) (msc EventServiceClient, err error) { conn, err := grpc.Dial("localh

在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错误:code=Unavailable desc=连接错误:desc=“传输:拨号时出错拨打tcp 127.0.0.1:9001:连接:连接被拒绝”

本地主机可能是ip6(::1)-尝试127.0.0.1:9001或0.0.0.0:9001以获取所有ip

确保可以ping主机,此外,防火墙未阻止无法ping主机,但防火墙看起来不错,没有任何问题。请提供有关您尝试连接到的gRPC服务器的更多信息(例如,您如何验证该服务器正在运行,操作系统/环境信息(docker?),您是否可以连接或使用类似工具)。否所有ip的本地主机均为ip4