zeromicro / go-zero

A cloud-native Go microservices framework with cli tool for productivity.
https://go-zero.dev
MIT License
29.37k stars 3.97k forks source link

go-zero 利用nacos做服务发现 rpc不通 #4376

Closed 18767156402 closed 2 months ago

18767156402 commented 2 months ago

项目背景 accountCenter--账号服务 workZone--核心作业区 baseService--基础服务提供者 其中 accountCenter服务-订阅accountCenter、workZone、baseService 3个rpc服务 workZone-订阅accountCenter的rpc服务 baseService-订阅accountCenter的rpc服务 其中workZone和baseService 都是正常启动,维度accountCenter启动报错

image

该问题困扰好久,看有人可以帮忙指导一下么

xiaocode337317439 commented 1 week ago

项目背景 accountCenter--账号服务 workZone--核心作业区 baseService--基础服务提供者 其中 accountCenter服务-订阅accountCenter、workZone、baseService 3个rpc服务 workZone-订阅accountCenter的rpc服务 baseService-订阅accountCenter的rpc服务 其中workZone和baseService 都是正常启动,维度accountCenter启动报错 image

该问题困扰好久,看有人可以帮忙指导一下么

请问解决了吗?

Issues-translate-bot commented 1 week ago

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Project background accountCenter--account service workZone--core operating area baseService--basic service provider accountCenter service-subscribe to accountCenter, workZone, baseService 3 rpc services workZone-subscribe to accountCenter's rpc service baseService-subscribe to accountCenter's rpc service among them Both workZone and baseService start normally, but dimension accountCenter reports an error when starting image

This problem has been bothering me for a long time. Is there anyone who can help guide me?

Has it been resolved?

xiaocode337317439 commented 1 week ago

项目背景 accountCenter--账号服务 workZone--核心作业区 baseService--基础服务提供者 其中 accountCenter服务-订阅accountCenter、workZone、baseService 3个rpc服务 workZone-订阅accountCenter的rpc服务 baseService-订阅accountCenter的rpc服务 其中workZone和baseService 都是正常启动,维度accountCenter启动报错 image

该问题困扰好久,看有人可以帮忙指导一下么

请问下最后你是怎么弄的?我也是总不成功

func NewGrpcClientConn(nc *NacosConfig, serverName string) *grpc.ClientConn {
    target := fmt.Sprintf(
        "nacos://%s:%d/%s?namespaceid=%s&groupname=%s",
        RegisterIp,
        RegisterPort,
        serverName,
        nc.NamespaceId,
        GroupName,
    )
    return zrpc.MustNewClient(zrpc.RpcClientConf{
        Target: target,
    }).Conn()
}
18767156402 commented 3 days ago

项目背景 accountCenter--账号服务 workZone--核心作业区 baseService--基础服务提供者 其中 accountCenter服务-订阅accountCenter、workZone、baseService 3个rpc服务 workZone-订阅accountCenter的rpc服务 baseService-订阅accountCenter的rpc服务 其中workZone和baseService 都是正常启动,维度accountCenter启动报错 image 该问题困扰好久,看有人可以帮忙指导一下么

请问下最后你是怎么弄的?我也是总不成功

func NewGrpcClientConn(nc *NacosConfig, serverName string) *grpc.ClientConn {
  target := fmt.Sprintf(
      "nacos://%s:%d/%s?namespaceid=%s&groupname=%s",
      RegisterIp,
      RegisterPort,
      serverName,
      nc.NamespaceId,
      GroupName,
  )
  return zrpc.MustNewClient(zrpc.RpcClientConf{
      Target: target,
  }).Conn()
}

go-zero的 文档没有问题,我是 写成了 Target: naocs://[usr:pwd]@host:8848/accountCenter?namespaceid=pre&timeout=5000s 其实[]这个符号要去掉,他们这里是表示用户名和密码可选的意思,后面我直接去掉[]就好了,不过最近发现nacos的服务发现还有别的问题,时间长了会api调rpc访问不通,换成etcd就没有这个问题