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

grpc: Unavailable response when gRPC server run in Docker #295

Open
noahdietz opened this issue Mar 15, 2022 · 4 comments
Open

grpc: Unavailable response when gRPC server run in Docker #295

noahdietz opened this issue Mar 15, 2022 · 4 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@noahdietz
Copy link
Collaborator

My code (written in Go, which just creates a Bucket via gRPC) succeeds when the storage_testbench server is run directly in a virtualenv, but fails when the server is running inside of a Docker container. The error reads rpc error: code = Unavailable desc = connection closed before server preface received.

The container was started with the following command:
docker run --name storage_testbench --rm -d -p 9000:9000 -p 8888:8888 gcr.io/cloud-devrel-public-resources/storage-testbench

The gRPC server was started with the following command:
curl -s "http://localhost:9000/start_grpc?port=8888"

@noahdietz noahdietz added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 15, 2022
@noahdietz
Copy link
Collaborator Author

docker ps produces the following:

CONTAINER ID   IMAGE                                                    COMMAND                  CREATED         STATUS        PORTS                                            NAMES
2759b71c6cff   gcr.io/cloud-devrel-public-resources/storage-testbench   "gunicorn --bind 0.0…"   2 seconds ago   Up 1 second   0.0.0.0:8888->8888/tcp, 0.0.0.0:9000->9000/tcp   storage_testbench

@noahdietz
Copy link
Collaborator Author

Worth noting, I am testing on macOS

@BenWhitehead
Copy link
Contributor

After a bit of diagnostics on a linux host I've found the following:

Run the image

docker run -it --rm --net=host gcr.io/cloud-devrel-public-resources/storage-testbench:v0.15.0

Start grpc

curl http://localhost:9000/start_grpc?port=9001

List bound ports:

$ sudo netstat -ntplv | grep '900'
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      4008468/python3     
tcp6       0      0 ::1:9001                :::*                    LISTEN      4008484/python3     
tcp6       0      0 127.0.0.1:9001          :::*                    LISTEN      4008484/python3 

The grpc server being started by gunicorn is only listening on localhost. We'll need to figure out some way to get it to use the same interface it's started with via --bind so that the server will be accessible from the Docker bridge network.

@coryan
Copy link
Contributor

coryan commented Mar 16, 2022

Maybe we should just replace localhost here:

port = server.add_insecure_port("localhost:%d" % port)

With the wildcard address [::]:%d' % port

@coryan coryan added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants