等待时间长,无法获得响应或上下文截止日期超过了go-micro

我有一个使用go-micro编写的grpc客户端,该客户端正在调用grpc微服务,该服务进一步连接到弹性搜索以获得搜索结果。

我正在创建我的grpc客户端的Web服务以及与Elasticsearch建立连接的grpc服务正在注册到同一注册表领事(已启用TLS配置)。

但是当客户端尝试调用grpc服务时,请求有时会成功,但有时会超过上下文超时。

我不确定领事是否花时间返回服务信息,或者是弹性搜索的连接问题,还是grpc客户端出现问题。

请帮助我解决这个问题这么久。预先感谢。

我尝试更改grpc客户端的连接池大小。 我尝试增加注册表ttl,注册表超时,但没有任何效果。

consul“ github.com/micro/go-plugins/registry/consul”

// my registry options 
func registryOptions(ops *registry.Options) {
        //ops.Timeout = time.Second * 30  
        ops.Secure = true
        ops.TLSConfig = &tls.Config{InsecureSkipVerify: true}
        ops.Addrs = []string{consulReg}
        log.Println("registry options : ",ops)
}

如果我取消注释超时,则会在服务运行状况检查(请求超时)(可能是阻塞查询的原因)期间收到领事观察错误。

// this is my web service  

reg = consul.NewRegistry(registryOptions)
                // reg := consul.NewRegistry(registryOptions)
                //reg.Watch()
                service := web.NewService(
                        web.Name("lena"),web.Address(serverPort),web.Advertise(advertize),//web.RegisterTTL(time.Second*30),//web.RegisterInterval(time.Second*10),web.Registry(reg),)

我也在使用--registry = consul

这是我的grpc客户端,正在调用弹性搜索服务

import(
grpcCl "github.com/micro/go-micro/client/grpc"
 "github.com/micro/go-micro/client/selector"
cache "github.com/micro/go-micro/client/selector/registry"
)

Client: grpcCl.NewClient(mclient.PoolSize(100),mclient.RequestTimeout(60*time.Second),mclient.Retries(3),mclient.Selector(cache.NewSelector(selector.Registry(reg))),mclient.Registry(reg)

这是我的弹性搜索客户端-

import "github.com/olivere/elastic"

elastic.NewClient(
                elastic.SetURL(es.Host1,es.Host2,es.Host3))

Grpc客户端应该及时从grpc服务获得响应,但是我已经超出了上下文截止日期

WY190521 回答:等待时间长,无法获得响应或上下文截止日期超过了go-micro

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3138404.html

大家都在问