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

Connection refused #1

Open
hanoisteve opened this issue May 15, 2019 · 12 comments
Open

Connection refused #1

hanoisteve opened this issue May 15, 2019 · 12 comments

Comments

@hanoisteve
Copy link

hanoisteve commented May 15, 2019

Im on Mac OS 10.13.6 and I get connection refused when I do any request against the services. I have tried changing the listener port number but still get error.

curl: (7) Failed to connect to localhost port 51051: Connection refused.

I still get this error after checking port etc. Im guessing this might be a docker thing or changes in the way envoy handles GRPC but not sure. Can someone clarify how connection refused occurs and how I can troubleshoot this?

@hanoisteve
Copy link
Author

This was on my side. I had not started the ServerMain.

@hanoisteve
Copy link
Author

hanoisteve commented May 16, 2019

After doing
./gradlew idea
User needs to reopen the project using the generated .ipr file.

This is clear for those who have used this command before but many of us have not.

@hanoisteve hanoisteve reopened this May 16, 2019
@hanoisteve
Copy link
Author

After checking that Server is running. I am still seeing connection refused. I have tried various different ports without luck. Is this and Envoy issue or a docker issue. In either case, from a practical perspective this is stopping me from running the demo.

@hanoisteve
Copy link
Author

Update: On a Mac running envoy with host network mode docker discards the published port numbers so that was causing the problem connecting, plus the ports were not published so not visible at all on a Mac. I am at least able to get envoy up and running with the following change to start-envoy.sh

sudo docker run -it --rm --name envoy -p 9901:9901 -p 10000:10000
-v "$(pwd)/reservation_service_definition.pb:/data/reservation_service_definition.pb:ro"
-v "$(pwd)/envoy-config.yml:/etc/envoy/envoy.yaml:ro"
envoyproxy/envoy

However, I am not seeing that the RPC service is reached. Listing the reservations is now empty.
Could you please comment on how I can get this demo running on a Mac with current envoy version?

@hanoisteve
Copy link
Author

I was able to get it working reservation creation working on the MAC with the following command:

sudo docker run -it --rm --name envoy -p 15000:15000 -p 10000:10000 -v "$(pwd)/reservation_service_definition.pb:/data/reservation_service_definition.pb:ro" -v "$(pwd)/envoy-config.yml:/etc/envoy/envoy.yaml:ro" envoyproxy/envoy

This publishes the port admin and port number but not the host port number 530000 where the Java server is running. I also removed the hosts network mode because this prevents publishing of the port. Here is the updated yaml: Note that I had to use host.docker.internal for the backend cluster rather than 127.0.0.1 due to visibility of the cluster.

access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 15000 }
#1

static_resources:
listeners:

  • name: main-listener
    address:
    socket_address: { address: 0.0.0.0, port_value: 10000 } Readme misspell #2
    filter_chains:
    • filters:
      • name: envoy.http_connection_manager
        config:
        stat_prefix: grpc_json
        codec_type: AUTO
        route_config:
        name: local_route
        virtual_hosts:
        - name: local_service
        domains: ["*"]
        routes:
        - match: { prefix: "/" , grpc: {}} # 3a grpc:{} means that requests are only forwarded if they are found in the grpc service definition, returning 404 for others
        route: { cluster: grpc-backend-services, timeout: { seconds: 60 } } #3b
        http_filters:

clusters:

  • name: grpc-backend-services #7
    connect_timeout: 1.25s
    type: logical_dns
    lb_policy: round_robin
    dns_lookup_family: V4_ONLY
    http2_protocol_options: {}
    hosts:
    • socket_address:
      address: host.docker.internal #8
      port_value: 53000

@hanoisteve
Copy link
Author

I am able to add reservations ok, but reservation list is returning empty.
coffee:Downloads Steven$ curl -v -X GET http://localhost:10000/v1/reservations
Note: Unnecessary use of -X or --request, GET is already inferred.

  • Trying ::1...
  • TCP_NODELAY set
  • Connected to localhost (::1) port 10000 (#0)

GET /v1/reservations HTTP/1.1
Host: localhost:10000
User-Agent: curl/7.54.0
Accept: /

< HTTP/1.1 200 OK
< content-type: application/grpc
< grpc-status: 0
< x-envoy-upstream-service-time: 30
< date: Thu, 16 May 2019 11:28:20 GMT
< server: envoy
< transfer-encoding: chunked
<

  • Connection #0 to host localhost left intact
    []

@toefel18
Copy link
Owner

toefel18 commented Jun 6, 2019

Hi, sorry for the late response, I'll look into this later!

@toefel18
Copy link
Owner

toefel18 commented Jun 6, 2019

could you issue a PR with the changes you made, I don't have a MAC but I can ask colleagues to test it on theirs. I would like to get it working on MAC, Linux and maybe windows as well :).

@klebersouza87
Copy link

Hello. What version did you use to run envoy? I'm trying "envoyproxy/envoy:v1.21.0" docker image and get an error below.

Protobuf message (type envoy.config.bootstrap.v3.Bootstrap reason INVALID_ARGUMENT:(static_resources.clusters[0]) hosts: Cannot find field.) has unknown fields

Can you help me? Thanks.

@toefel18
Copy link
Owner

Hello @klebersouza87 the command I used appeared to be:

    docker run -it --rm --name envoy --network="host" \
             -v "$(pwd)/envoy-config.yml:/etc/envoy/envoy.yaml:ro" \
             envoyproxy/envoy

This was done at 2018-11-04, so if possible, I would look for an envoy image around that time.

https://hub.docker.com/r/envoyproxy/envoy/tags?ordering=-last_updated

random old image: docker pull envoyproxy/envoy:0cb60a38150212c1c64cc3f75b8f814e918d4c47

@klebersouza87
Copy link

With this image I can run envoy container, but ports is not mapped. Did you have this problem? I'm using your project without any changes.

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
02c35de95c78 envoyproxy/envoy:0cb60a38150212c1c64cc3f75b8f814e918d4c47 "/bin/bash" 35 seconds ago Up 34 seconds envoy

@toefel18
Copy link
Owner

toefel18 commented Jan 30, 2022

Hi, sorry for the slow response. I was busy this weekend.

The ports are indeed not mapped that way I guess. In this file I see that I use --network="host" which means it does not get a separate network but just runs on the host net, so it would be accessible on localhost without port mapping. Not sure if this is still supported due to security, but you could try that.

https://github.com/toefel18/transcoding-grpc-to-http-json/blob/master/start-envoy.sh


# check if sudo is required to run docker
if [ "$(groups | grep -c docker)" -gt "0" ]; then
    echo "Envoy will run at port 51051 (see envoy-config.yml)"
    docker run -it --rm --name envoy --network="host" \
             -v "$(pwd)/reservation_service_definition.pb:/data/reservation_service_definition.pb:ro" \
             -v "$(pwd)/envoy-config.yml:/etc/envoy/envoy.yaml:ro" \
             envoyproxy/envoy
else
    echo "you are not in the docker group, running with sudo"
    echo "Envoy will run at port 51051 (see envoy-config.yml)"
    sudo docker run -it --rm --name envoy --network="host"\
             -v "$(pwd)/reservation_service_definition.pb:/data/reservation_service_definition.pb:ro" \
             -v "$(pwd)/envoy-config.yml:/etc/envoy/envoy.yaml:ro" \
             envoyproxy/envoy
fi

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

3 participants