"getsockopt: connection refused error" while talking to local grpc server


#1

Hello,

I am trying to get tyk (from docker) to talk to my grpc java server running locally. I see the following error message when it tries to connect to the grpc server

tyk_gateway_1 | 2017/01/19 00:28:59 grpc: addrConn.resetTransport failed to create client transport: connection error: desc = "transport: dial tcp 127.0.0.1:50051: getsockopt: connection refused"; Reconnecting to { <nil>}

It seems to have successfully loaded the bundle as seen in the logs

tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="Loading API" api_name="Test Bundle API" tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="Loading existing bundle: bundle.zip" tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="----> Loading bundle: bundle.zip" tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="Loading API" api_name=Portal tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="Loading API" api_name=Portal tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="Loading API" api_name="Portal API" tyk_gateway_1 | time="Jan 19 00:28:59" level=info msg="----> Using bundle: bundle.zip"

Here is how my tyk.conf for grpc looks like :

"coprocess_options": { "enable_coprocess": true, "coprocess_grpc_server": "tcp://dockerhost:50051" }, "enable_bundle_downloader": true, "bundle_base_url": "http://76426195.ngrok.io/", "global_session_lifetime": 100, "force_global_session_lifetime": false, "max_idle_connections_per_host": 100

Why is tyk not able to connect to the grpc server running on localhost:50051 ?

Thanks,
Namrata


#2

Is the Java server running inside the docker container or in another container, or on your local os?


#3

It is running on local OS


#4

Ok, that means that the Tyk process, because it is running in the container, will be targeting the loopback interface of the container, and so querying port 50051 on the docker container, not your local OS.

You’ll need to set an explicit IP, this SO question is relevant to your scenario:


#5

Thanks for the link. I am running docker for mac. I just created a dockerfile for the grpc-java server and then used “links” in the docker-compose file. That did the trick.