I have a grpc client written using go-micro, which is making a call to grpc microservice which is further connecting to elastic search to get the search result.
My web service where I am creating my grpc client and the grpc service making connection to elasticsearch are registering to same registry consul (enabled for TLS configuration).
But when client tries to call the grpc service sometimes the request gets successful but sometimes I get the context timeout exceeded.
I am not sure whether consul is taking time to return the service information or it is the connection issue with elastic search or there is an issue with grpc client .
Please help I am stuck on this issue for so long. Thanks in advance.
I tried changing the connection pool size for my grpc client. I tried increasing registry ttl , registry timeout but nothing works.
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)
}
If I uncomment the timeout I get consul watch error which while service health check (request timeout) (maybe coz of blocking query).
// 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),
)
I am also using --registry=consul
This is my grpc client that is calling elastic search service
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)
This is my elastic search client -
import "github.com/olivere/elastic"
elastic.NewClient(
elastic.SetURL(es.Host1, es.Host2, es.Host3))
Grpc client should get the timely response from grpc service but I am getting context deadline exceeded