0

I am following the GRPC tutorials here https://grpc.io/docs/languages/python/.

In greeter_client.py over here - https://github.com/grpc/grpc/blob/master/examples/python/helloworld/greeter_client.py, instead of using

with grpc.insecure_channel('localhost:50051') as channel:

(the above code works fine), I use the following -

with grpc.insecure_channel('XX.XX.XX.XX:50051') as channel:

where XX.XX.XX.XX is my laptop's public IP address from https://www.whatsmyip.org/.

I get this error

raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.UNAVAILABLE
        details = "failed to connect to all addresses; last error: UNKNOWN: ipv4:XX.XX.XX.XX:50051: Failed to connect to remote host: Connection refused"
        debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNKNOWN: ipv4:XX.XX.XX.XX:50051: Failed to connect to remote host: Connection refused {created_time:"2022-12-29T23:18:44.033798+00:00", grpc_status:14}"

does anyone know why this happens? I think this might be a MacOS issue. Mine is a MacOS Monterey, and I have the firewalls all disabled, so I am not sure what else I should be doing. Is this expected behaviour?

mndl
  • 17
  • 3
  • Did you route the traffic thru your router/firewall – Daniel A. White Dec 29 '22 at 23:32
  • hi Daniel, what do you mean by "route the traffic thru your router/firewall"? Is there something I should be adding in the code? Why is my laptop's public IP address not sufficient? – mndl Dec 29 '22 at 23:48

1 Answers1

0

Turns out, the best way to deal with this is by using ngrok. The steps would be something like -

  1. Download ngrok (can use brew install ngrok)
  2. Set up forwarding using something like ngrok tcp 50051
  3. Once you click 'enter', there will be a field under Forwarding, which you should then use. Remember to remove the tcp://
mndl
  • 17
  • 3