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 Hello World Guide is out of date for Windows and Mac users #436

Closed
itsalexyue opened this issue Jan 14, 2019 · 10 comments
Closed

gRPC Hello World Guide is out of date for Windows and Mac users #436

itsalexyue opened this issue Jan 14, 2019 · 10 comments

Comments

@itsalexyue
Copy link

itsalexyue commented Jan 14, 2019

The README.md doc for the Hello World guide is out of date for Windows and Mac users. Specifically, the envoy.yaml file should be updated with a clarification for Mac and Windows users that instead of using address: localhost, they should use address: host.docker.internal under the clusters field due to idiosyncrasies with how the docker VM is configured on these machines.

Furthermore, the command to launch the Envoy proxy under these OSes is slightly different (--network=host should be removed) so the command should be:

$ docker run -d -p 8080:8080 helloworld/envoy
@chiamtc
Copy link

chiamtc commented Jan 16, 2019

Thank you so much. I was unable to get this started after your suggestion initially because I didn't kill all the docker processes/container after changes.

@moabtools
Copy link

I need another suggestion.
Windows 10 Corp, Envoy in docker container with envoy.yaml config from example page.
Simple copy-paste from helloworld example, did your trick with host.docker.internal under the clusters field.
Still getting error "{code: 14, message: "Http response at 400 or 500 level"}" in browser.
What I'm doing wrong?

@chiamtc
Copy link

chiamtc commented Jan 18, 2019

Did you build docker container and run it properly? Caveats in the hello world tutorial - it's quite outdated in the docker part - use docker run -d -p 8080:8080 helloworld/envoy as --network=host flag is no longer supported.

@moabtools
Copy link

I build docker container from PowerShell with command docker build .

My Dockerfile:

FROM envoyproxy/envoy:latest
COPY envoy.yaml /etc/envoy/envoy.yaml
CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml

envoy.yaml:

admin:
  access_log_path: /tmp/admin_access.log
  address:
    socket_address: { address: 0.0.0.0, port_value: 9901 }

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address: { address: 0.0.0.0, port_value: 8080 }
    filter_chains:
    - filters:
      - name: envoy.http_connection_manager
        config:
          codec_type: auto
          stat_prefix: ingress_http
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match: { prefix: "/" }
                route:
                  cluster: echo_service
                  max_grpc_timeout: 0s
              cors:
                allow_origin:
                - "*"
                allow_methods: GET, PUT, DELETE, POST, OPTIONS
                allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
                max_age: "1728000"
                expose_headers: custom-header-1,grpc-status,grpc-message
                enabled: true
          http_filters:
          - name: envoy.grpc_web
          - name: envoy.cors
          - name: envoy.router
  clusters:
  - name: echo_service
    connect_timeout: 0.25s
    type: logical_dns
    http2_protocol_options: {}
    lb_policy: round_robin
    hosts: [{ socket_address: { address: host.docker.internal, port_value: 9090 }}]

I run docker with command:

docker run -d -p 8080:8080 envoyproxy/envoy:latest

Result:
{code: 14, message: "Http response at 400 or 500 level"}

iennacca added a commit to iennacca/aconcagua that referenced this issue Jan 22, 2019
- created new README off old addenda file
- edited envoy.yaml and modified README as per grpc/grpc-web#436
@oinke
Copy link

oinke commented Mar 2, 2019

I have added all the changes recommended to get the hello world example to run into this repo https://github.com/oinke/gprc-hello

The terminal still shows:
server_1 | E0302 08:41:34.225022613 7 http_server_filter.cc:271] GET request without QUERY
and when i browse localhost:8080 i can see
upstream connect error or disconnect/reset before headers. reset reason: remote reset

Running on macOS Mojave 10.14.2 with Docker version 18.09.2, build 6247962

iennacca added a commit to iennacca/grpc-web that referenced this issue May 5, 2019
stanley-cheung pushed a commit that referenced this issue May 7, 2019
@stanley-cheung
Copy link
Collaborator

Notes added to doc.

@gsantopaolo
Copy link

gsantopaolo commented Nov 5, 2019

@stanley-cheung shall we open this again? the envoy.yaml file is using a property (hosts) that is deprecated https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/cds.proto#envoy-api-file-envoy-api-v2-cds-proto

@YaredTaddese
Copy link

@gsantopaolo yes it should be opened. It is not still working on the latest Mac.

@treylee
Copy link

treylee commented Mar 2, 2021

is this command still working? windows docker

docker run -d -v "$(pwd)"/envoy.yaml:/etc/envoy/envoy.yaml:ro
-p 8080:8080 -p 9901:9901 envoyproxy/envoy:v1.17.0

i tried as well

docker run -d -v ./envoy.yaml:/etc/envoy/envoy.yaml:ro
-p 8080:8080 -p 9901:9901 envoyproxy/envoy:v1.17.0

First command doesnt execute
Second command the following error
status: Downloaded newer image for envoyproxy/envoy:v1.17.0
docker: Error response from daemon: source /var/lib/docker/overlay2/f28fb10fe83102e1a6e097b758bce7854f5047ebc20489805e9ea11b52c0c257/merged/etc/envoy/envoy.yaml is not directory

@b26
Copy link

b26 commented May 1, 2021

For reference i'm using Windows 10 Pro but do all my development stuff using WSL2

So if you're using docker-compose to run envoy and you have a grpc service, this is what I had to do

// docker-compose
version: '3.4'

services:

  envoy:
    image: envoyproxy/envoy-dev
    ports:
      - 9901:9901
      - 8080:8080
    volumes:
      - ./envoy_tests/envoy-grpc.yaml:/etc/envoy/envoy.yaml

  chat_service:
    build:
      context: ./microservices
      dockerfile: chat.Dockerfile
    ports:
      - 50051:50051

  gateway_service:
    build:
      context: ./microservices
      dockerfile: gateway.Dockerfile
    ports:
      - 50050:50050

make sure you also update your connection

	connection, err := grpc.Dial("chat_service:50051", grpc.WithInsecure());

this can stay the same for both gateway_service and chat_service

	listen, err := net.Listen("tcp", "0.0.0.0:50050");

your cluster as follows

  clusters:
  - name: gateway_service
    connect_timeout: 0.25s
    type: logical_dns
    http2_protocol_options: {}
    lb_policy: round_robin
    # win/mac hosts: Use address: host.docker.internal instead of address: localhost in the line below
    load_assignment:
      cluster_name: cluster_0
      endpoints:
        - lb_endpoints:
            - endpoint:
                address:
                  socket_address:
                    address: gateway_service
                    port_value: 50050

you'll notice the only difference is i'm using address: gateway_service instead of host.docker.internal or 0.0.0.0 . I'm pretty sure localhost, host.docker.internal, and 0.0.0.0 will work if you're launching all your service under docker-compose because docker-compose will create a new network for you.

To ensure that your connection is working, navigate to http://localhost:9901/clusters

and ensure that your service is not failing to receive connections

gateway_service::192.168.16.3:50050::cx_active::2
gateway_service::192.168.16.3:50050::cx_connect_fail::0
gateway_service::192.168.16.3:50050::cx_total::2

I'm more than happy to update the readme with some new examples. cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants