I am trying to create a grpc-web client to connect to my grpc server. I already have my grpc server written in C++ and it works well with C# client, everything is okay and tested. Right now I am trying to create a js client to connect to my service. So what I would expect is to return a simple "hello" back to me but what I get is: "net::ERR_CONNECTION_REFUSED".
I have fallowed this tutorial: hello world and also tried that one: fron proxy from grpc-web
I have generated proto files succesfuly. my client looks like that:
const {HelloRequest, HelloResponse} = require('./definitions_pb.js');
const {GreeterClient} = require('./definitions_grpc_web_pb.js');
var echoService = new GreeterClient('http://192.168.88.150:8080');
var request = new HelloRequest();
request.setName('Mark');
echoService.sayHello(request, {}, function(err, response) {
// ...
});
what I am confused about is the proxy that I have to run in docker, so I suspect it is messed up. My envoy.yaml file looks like that:
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9091 }
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: greeter_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: greeter_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
hosts: [{ socket_address: { address: 192.168.88.150, port_value: 50051 }}]
and Docker file:
FROM envoyproxy/envoy:latest
COPY ./envoy.yaml /etc/envoy/envoy.yaml
CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml
I use " npx webpack client.js
" to create main.js.
To start envoy proxy I do as they say in the tutorial:
>> docker build -t envoy -f ./Dockerfile .
>> docker run -d -p 8080:8080 envoy
and after starting my server, running that docker stuff and starting my web:
py -m http.server 8081
I get that error I have mentioned at the start. I was thinking of CORS blocking but it is enabled in the envoy file. I would really appreaciate any help.
@@Edit
So I have also tried that envoy-front and I have problems with curl
instruction in that example. Mainly I get: Invoke-WebRequest : Unable to connect to the remote server
. I susperct it has to do with my docker machine but I do not know what. Oh and also I am using Docker-Toolbox and not Docker for Windows because mym system does not support Docker for Windows.