connectrpc / envoy-demo

Demonstration of how to use the new Connect-gRPC Envoy filter, available in Envoy v1.26+.
Apache License 2.0
25 stars 7 forks source link

Error when migrate to connect_grpc_bridge (google.protobuf.message.DecodeError) #8

Closed fijemax closed 1 year ago

fijemax commented 1 year ago

Hello, I am trying to migrate my project on buf connect and I have the following error in my browser console.

My grpc framework is based on django and https://github.com/socotecio/django-socio-grpc My envoy layer is up to 1.26

Below my front use case:

import { createPromiseClient } from "@connectrpc/connect";
import { createConnectTransport } from "@connectrpc/connect-web";

import { UserController } from './proto/js/sample_back/user_connect'
import { UserListRequest } from './proto/js/sample_back/user_pb'

// This transport is going to be used throughout the app
const transport = createConnectTransport({
  baseUrl: "http://localhost:20251",
});

async function user_list_test(auth) {
  const request = new UserListRequest();
  const headers = new Headers();
  const promiseClient = createPromiseClient(UserController, transport);

  headers.set("Headers", JSON.stringify(
    {
      "Authorization": `Bearer ${auth.userData.access_token}`
    }
  ))

  const res = await promiseClient.list(
    request,
    {
      headers: headers
    }
  );
}

Bellow the browser error: image

Bellow my envoy.yaml:

admin:
  address:
    socket_address: { address: 0.0.0.0, port_value: 9090 }

static_resources:
  listeners:
  - name: listener_0
    address:
      socket_address: { address: 0.0.0.0, port_value: 20251 }
    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
          stat_prefix: ingress_http
          access_log:
          - name: envoy.access_loggers.stdout
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
          - name: envoy.access_loggers.stderr
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StderrAccessLog
          codec_type: AUTO
          route_config:
            name: local_route
            virtual_hosts:
            - name: local_service
              domains: ["*"]
              routes:
              - match: { prefix: "/" }
                route: { cluster: service_0 }
              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,filters,pagination,headers,connect-protocol-version
                max_age: "1728000"
                expose_headers: custom-header-1,grpc-status,grpc-message,filters,pagination,headers,connect-protocol-version
          http_filters:
          - name: envoy.filters.http.connect_grpc_bridge
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.connect_grpc_bridge.v3.FilterConfig
          - name: envoy.filters.http.grpc_web
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.grpc_web.v3.GrpcWeb
          - name: envoy.filters.http.cors
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.cors.v3.Cors
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
  clusters:
  - name: service_0
    connect_timeout: 0.25s
    type: STRICT_DNS
    lb_policy: ROUND_ROBIN
    load_assignment:
      cluster_name: service_0
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: sample-back-grpc
                port_value: 50051
    typed_extension_protocol_options:
      envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
        "@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
        explicit_http_config:
          http2_protocol_options:
            max_concurrent_streams: 100

The only envoy log I have: image

Any help on this issue ?

Best regards, Max

fijemax commented 1 year ago

i was using wrong transport createConnectTransport instead createGrpcWebTransport