通过 Envoy 向 python 服务器发出 GRPC-Web React 请求

时间:2021-03-25 14:36:54

标签: python reactjs grpc envoyproxy grpc-web

  1. 当我从 react 中点击 grpc 请求时,我收到错误 503。

      **error -** POST http://localhost:8080/service/CreateAuth 503 (Service Unavailable)
    
  2. 我在 localhost:8080

    上遇到以下错误
    upstream connect error or disconnect/reset before headers. reset reason: connection failure.
    
  3. Python 服务器端口为 50001。

  4. React 在 3000 上运行。

下面是我的 envoy.yml 配置。

envoy.yml:

      admin:
      access_log_path: /tmp/admin_access.log
      address:
        socket_address: { address: 0.0.0.0, port_value: 9901 }

    static_resources:
      listeners:
        - name: listener_0
          address:
            socket_address: { address: 0.0.0.0, port_value: 8080 }
          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: echo_service
                                timeout: 0s
                                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: echo_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: localhost
                          port_value: 50001

docker.compose.yml

      version: '3'
      services:
        envoy:
          image: envoyproxy/envoy-dev:25d50667f96ee98d7f6cad8e190a3798ea5cd66f
          ports:
            - '10000:10000'
            - '9901:9901'
            - '8080:8080'
          volumes:
            - ./envoy-config.yml:/etc/envoy/envoy.yaml
          networks:
            - xyz

      networks:
        xyz:
          driver: bridge

谁能告诉我特使设置有什么问题。 作为反应,我们正在通过 8080 端口重定向请求,正如我在第一点添加的那样。

0 个答案:

没有答案
相关问题