python - 通过 Envoy 向 Python 服务器发出 GRPC-Web React 请求
问题描述
当我从反应中点击 grpc 请求时,我收到错误 503。
**error -** POST http://localhost:8080/service/CreateAuth 503 (Service Unavailable)
我在localhost:8080上遇到错误
upstream connect error or disconnect/reset before headers. reset reason: connection failure.
Python 服务器端口为 50001。
React 在 3000 上运行。
下面是我的 envoy.yml 配置。
特使.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 端口重定向请求,正如我在第一点中添加的那样。
解决方案
推荐阅读
- javascript - 单击菜单项不会向下滚动到页面上的部分
- r - 您可以将 XML 解析为 R Shiny 并作为数据框查看吗?
- python - 为什么当我尝试从 C++ 调用 python 函数时出现“无属性错误”
- reactjs - 在使用 nginx 服务的 docker 容器中运行的 React 应用程序是空白的
- javascript - .js 文件的 Http-Server 奇怪行为
- python - 是否应该将仅限管理员的字段提取到与原始模型具有 OneToOne 关系的专用模型中?
- bluetooth-lowenergy - IOS广告上的CN1Cordova插件不起作用
- excel - 在 Excel 中,为什么以下 VBA 需要这么长时间才能运行?
- python - 如何在 Python Dash 中将 matlab 图绘制为 html
- java - 如何在另一个类中移动 @Override 方法