Hi!
I just try to run the hello world example to try this project but I'm facing a upstream connect error or disconnect/reset before headers error when I try to fetch http://localhost:8081/ in my browser.
The code of my helloworld project is identical to those you give in the README.md (I ended up copying/plasting files). The compilation of the protoc-gen-grpc-web and the generation with protoc are well done too.
The only issue happens when I try to run the envoy image with this command: docker run -d -p 8080:8080 --network=host helloworld/envoy. I have:
WARNING: Published ports are discarded when using host network modeHttp response at 400 or 500 level.So I tried without the host network (like this: docker run -d -p 8080:8080 helloworld/envoy) and it's a bit better: no more Docker warning and a 200 on the http://localhost:8080/helloworld.Greeter/SayHello but I have this error now: upstream connect error or disconnect/reset before headers.
Also, when I watch the /clusters it seems that the greeter_service::[::]:0::cx_connect_fail is incremented on each try. So it seems to be a connection problem.
Does someone have an idea? Thanks a lot! :)
Are you using Mac? --network=host may not work in Mac. You might have to use the --link node-server:node-server flag to start the Envoy server, add --name node-server when starting the Node backend server, and use node-server when referencing the backend address in the envoy.yaml.
Thanks @stanley-cheung for your quick answer!
Indeed, I'm using MacOs. Your advice was really helpful, thanks!
In order to make it work, I created a docker compose file.
I think it could be a good idea to include it in the helloworld guide in order to reduce the friction during the onboarding of new users. What do you think?
Here is the changes that I have made:
Note that link is a legacy feature so I rather chose a network. Can you confirm that it will work on other OS (Linux, Windows, etc.)?
version: '3'
services:
envoy:
build:
context: .
dockerfile: envoy.Dockerfile
ports:
- '8080:8080'
- '9901:9901'
networks:
- server-net
server:
build:
context: .
dockerfile: server.Dockerfile
ports:
- '9090:9090'
networks:
- server-net
networks:
server-net:
FROM node
WORKDIR /helloworld
COPY ./package.json ./package.json
RUN npm install
COPY ./helloworld.proto ./helloworld.proto
COPY ./server.js ./server.js
CMD node ./server.js
clusters:
- name: greeter_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
- hosts: [{ socket_address: { address: localhost, port_value: 9090 }}]
+ hosts: [{ socket_address: { address: server, port_value: 9090 }}]
Tell me if you are interested by these changes, I could make a PR. :)
@QuentinBrosse Your docker-compose works, tested on Windows 10, Docker 18.06.1-ce-win73 (19507). Thanks so much!
Docker-compose works on Fedora 29, but still have the same error: 14, upstream connect error or disconnect/reset before headers. Copy/Pasted code from Hello World example. Kinda Envoy can't reach server?
Yes, the 14, upstream connect error or disconnect/reset before headers message means that envoy can't establish the connection to the target (cluster).
issue #436 helped me if anyone in the future isn't using docker-compose.yaml
just to keep this up-to-date, using docker-compose it doesn't require a dedicated network as in above example. All that's required is the correct socket_address in the envoy.yaml cluster configuration, being the name and port of the serving service, i.e. "server" in above example.
Most helpful comment
Thanks @stanley-cheung for your quick answer!
Indeed, I'm using MacOs. Your advice was really helpful, thanks!
In order to make it work, I created a docker compose file.
I think it could be a good idea to include it in the helloworld guide in order to reduce the friction during the onboarding of new users. What do you think?
Here is the changes that I have made:
docker-compose.yaml
Note that link is a legacy feature so I rather chose a network. Can you confirm that it will work on other OS (Linux, Windows, etc.)?
server.Dockerfile
envoy.yaml:
Tell me if you are interested by these changes, I could make a PR. :)