Envoy proxy is not translating http1 requests from the browser to http2

  docker, envoyproxy, grpc, java, reactjs

I have the frontend running on port 3000 (based on react) and the java backend is running on port 50051.
since gRPC is using HTTP2 protocol I’m using Envoy proxy to convert the http requests coming from react (basically the browser which is HTTP1) to HTTP2 so the java backend is able to read them.
Unfortunately this is not happening and Envoy somehow is not doing the translation and I get this error in the java backend:

io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception:
Unexpected HTTP/1.x request: OPTIONS /greet.GreetingService/greet

Now as mentioned in the error, the java backend is complaining about receiving HTTP1 requests, which means the proxy is not doing its job.
This is the config file I’m using for Envoy:

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address: { address: 127.0.0.1, port_value: 3000 }
      filter_chains:
        - filters:
            - name: envoy.filters.network.http_connection_manager
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
                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_stream_duration:
                              grpc_timeout_header_max: 0s
                      cors:
                        allow_origin_string_match:
                          - prefix: "*"
                        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
                http_filters:
                  - name: envoy.filters.http.grpc_web
                  - name: envoy.filters.http.cors
                  - name: envoy.filters.http.router
  clusters:
    - name: greeter_service
      connect_timeout: 0.25s
      type: logical_dns
      http2_protocol_options: {}
      lb_policy: round_robin
      load_assignment:
        cluster_name: cluster_0
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: 127.0.0.1
                      port_value: 50051

As you can see in the config file I’m making the proxy to listen to the port 3000 (because the frontend is running on it) and send them to the port 50051 (where the java backend is running) after the translation.
I’m running the proxy via docker-compose:

version: '3'
services:
  envoy:
    image: envoyproxy/envoy-dev:b145180d17cac80aa5f9a7801429d52017fea6d1
    volumes:
      - ./envoy.yaml:/etc/envoy/envoy.yaml

I’m running the java backend via Intellij IDEA, and I’m running the frontend via npm start.
And whenever I fire a request from the frontend I don’t see any logs in the envoy container, I feel like the requests are not intercepted by the proxy.
So I’m wondering could it be because I’m not running the frontend and backend in docker containers like I’m doing for the proxy? not sure though!

Source: Docker Questions

LEAVE A COMMENT