Skip to content
New issue

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

How to enable grpclb? #2854

Closed
blazej24 opened this issue Jun 5, 2019 · 3 comments
Closed

How to enable grpclb? #2854

blazej24 opened this issue Jun 5, 2019 · 3 comments

Comments

@blazej24
Copy link

blazej24 commented Jun 5, 2019

I would like to use grpclb load balancing in my go client. I have a custom loadbalancer implementing grpclb protocol, and everything works for Java clients (it is easy to enable it by simple option -Dio.grpc.internal.DnsNameResolverProvider.enable_grpclb=true, and then I can create a channel with .forTarget("hello.mimgrpc.me")).

How to enable it in go client? By default, if I will use my domain with proper SRV records as my endpoint, I get something like this:

INFO: 2019/06/05 20:20:14 parsed scheme: ""
INFO: 2019/06/05 20:20:14 scheme "" not registered, fallback to default scheme
INFO: 2019/06/05 20:20:14 ccResolverWrapper: sending update to cc: {[{hello.mimgrpc.me 0 }] }
INFO: 2019/06/05 20:20:14 ClientConn switching balancer to "pick_first"
WARNING: 2019/06/05 20:20:14 grpc: addrConn.createTransport failed to connect to {offers-api.core.creativecdn.net 0 }. Err :connection error: desc = "transport: Error while dialing dial tcp: address hello.mimgrpc.me: missing port in address". Reconnecting...
INFO: 2019/06/05 20:20:14 pickfirstBalancer: HandleSubConnStateChange: 0xc000150010, CONNECTING
INFO: 2019/06/05 20:20:14 pickfirstBalancer: HandleSubConnStateChange: 0xc000150010, TRANSIENT_FAILURE

I tried to add a grpc.DialOption: grpc.WithBalancerName(roundrobin.Name) or grpc.WithBalancerName("grpclb"), but I get either compilation (undefined: grpclb) or runtime (panic: grpc.WithBalancerName: no balancer is registered for name grpclb) errors.

I also tried to import "google.golang.org/grpc/balancer/grpclb", but it doesn't help.

It has to be something very simple, but I can't make it work - could you help?

@menghanl
Copy link
Contributor

menghanl commented Jun 5, 2019

Please try the following steps:

  1. import _ "google.golang.org/grpc/balancer/grpclb"
    • this is to install grpclb balancer
  2. grpc.Dial("dns:///hello.mimgrpc.me")
    • the prefix is to tell client to use dns resolver (the default is passthrough). Note the triple slashes.

@dfawley
Copy link
Member

dfawley commented Jun 13, 2019

@blazej24 was the above information helpful? Have you gotten this working?

@blazej24
Copy link
Author

Sorry for the delay. Yes, it helped, consider adding this information to documentation about grpclb or somewhere else, to make this easier to find.

I've got another problem while trying to run this; I will write about it, because it might be helpful for someone. Because I am running my Go application as a Docker container, I have to add --dns 8.8.8.8 flag to ther docker run command. Without it, I got:

grpc: failed dns SRV record lookup due to lookup hello.mimgrpc.me on 127.0.0.53:53: cannot unmarshal DNS message.

@dfawley dfawley closed this as completed Jun 20, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants