node.js - 未见特使

标签 node.js docker ubuntu grpc envoyproxy

我正在使用 Ubuntu v. 21.04 运行 React , 和 Node.js应用程序,使用 grpc .这是我的特使配置:

static_resources:
  listeners:
    - name: listener_0
      address:
        socket_address: { address: 0.0.0.0, port_value: 8082 }
      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: 0.0.0.0
                      port_value: 50052
我的 react docker-compose文件:
version: '3.9'

services:
  envoy:
    build: .
    ports:
      - 8082:8082
前端dockerfile :
FROM envoyproxy/envoy:v1.17.0

COPY ./envoy.yaml /etc/envoy/envoy.yaml

CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml -l trace --log-path /tmp/envoy_info.log
我的 Node.js docker-compose :
version: '3.9'
services:
  postgres:
    image: postgres:13.3
    env_file:
      - ./.env.development
    ports:
      - '5432:5432'
  states-service:
    build:
      context: .
      dockerfile: Dockerfile.dev
      args:
        - NPM_TOKEN=${NPM_TOKEN}
    ports:
      - '50052:50052'
    volumes:
      - ./src:/app/src
      - /node_modules
    env_file:
      - ./.env.development
    environment:
      - KNEX_CONNECTION_HOST=postgres
    depends_on:
      - postgres
它从端口 50052 开始.
但是当我尝试使用 BloomRPC 获取任何东西时调用0.0.0.0:8082 , 与 web模式,通话将永远持续下去。
enter image description here
但是当我调用 localhost:50052在 grpc 模式下,它可以工作。我错过了什么?

最佳答案

如果同时没有解决,试试这个集群配置:

- name: echo_service
  connect_timeout: 0.25s
  type: STRICT_DNS
  lb_policy: ROUND_ROBIN
  http2_protocol_options: {}
  dns_resolvers:
    - socket_address:
        address: 127.0.0.11
        port_value: 53
  load_assignment:
    cluster_name: cluster_0
    endpoints:
      - lb_endpoints:
          - endpoint:
              address:
                socket_address:
                  address: gateway.docker.internal
                  port_value: 50052
但是最好使用一个 docker-compose 文件并在 envoy 集群配置中使用容器名称作为地址,但这只有在 envoy 和 Node 容器使用相同的 docker 网络时才有可能。

关于node.js - 未见特使,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69708793/

相关文章:

javascript - JSON.parse( ) 的数值变化

node.js - 插入数据时如何阻止 sequelize 创建不需要的主键?

docker - 如何将 docker 容器的镜像移动到永久磁盘?

docker - 与Docker Compose不同的env文件但相同的yml?

iphone - 转换视频时保持纵横比? - ffmpeg

node.js - Facebook OAuth2 不提供用户电子邮件

javascript - 如何在 Node-Red 网页上显示负载

ubuntu - 无法在 Docker 中运行 nuttcp

mysql - 无法连接到数据库服务器 MySQL Workbench 隧道错误

ruby-on-rails - PDFKit 不会在 Ubuntu on rails 上呈现