diff --git a/client/main.go b/client/main.go index 73d6333..3b9312d 100644 --- a/client/main.go +++ b/client/main.go @@ -13,7 +13,8 @@ import ( func main() { consul.FindServer() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - conn, err := grpc.DialContext(ctx, "consul://192.168.8.254:8500/demo", grpc.WithBlock(), grpc.WithInsecure(), grpc.WithBalancerName("round_robin")) + conn, err := grpc.Dial("127.0.0.1:9001", grpc.WithBlock(), grpc.WithInsecure()) + // conn, err := grpc.DialContext(ctx, "consul://127.0.0.1:8500/demo", grpc.WithBlock(), grpc.WithInsecure(), grpc.WithBalancerName("round_robin")) if err != nil { cancel() } diff --git a/consul/consul-service.go b/consul/consul-service.go index 9959250..b418e78 100644 --- a/consul/consul-service.go +++ b/consul/consul-service.go @@ -8,7 +8,7 @@ import ( ) const ( - consulAddr string = "192.168.8.254:8500" + consulAddr string = "127.0.0.1:8500" ) //Register 注册服务到consul