We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在线上RPC服务中(k8s pod中运行)调用PingMetricsClient返回service discovery error: no service found 单独写脚本在pod中执行返回正常
var ( MetricsClient metricsservice.Client ) func InitMetricsClient(ctx context.Context, consul_host string, consul_port string) (err error) { addr := fmt.Sprintf("%s:%s", consul_host, consul_port) r, err := consul.NewConsulResolver(addr) if err != nil { Debuger(ctx, "NewConsulResolver err:%s", err.Error()) return } MetricsClient, err = metricsservice.NewClient( "ops.infra.metrics", client.WithMuxConnection(1), // mux client.WithRPCTimeout(2*time.Second), // rpc timeout client.WithConnectTimeout(2*time.Second), // conn timeout // client.WithFailureRetry(retry.NewFailurePolicy()), // retry client.WithResolver(r), // resolver ) if err != nil { Debuger(ctx, "InitMetricsClient err:%s", err.Error()) return } Debuger(ctx, "InitMetricsClient Success consul_host: %s consul_port: %s ", consul_host, consul_port) return nil } func PingMetricsClient(ctx context.Context) bool { req := &stock.Req{} option := callopt.WithRPCTimeout(1 * time.Second) _, err := MetricsClient.Ping(context.Background(), req, option) if err != nil { Debuger(ctx, "PingMetricsClient err:%s", err.Error()) //这里返回service discovery error: no service found return false } return true }
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
针对报错,意思是 找不到可用实例。 这里最好参考下 服务提供者,在注册时的代码,比如注册的地址、或者服务实例的健康检查等等。
jayantxie
No branches or pull requests
问题描述
在线上RPC服务中(k8s pod中运行)调用PingMetricsClient返回service discovery error: no service found
单独写脚本在pod中执行返回正常
The text was updated successfully, but these errors were encountered: