【发布时间】:2022-01-21 08:31:48
【问题描述】:
服务状态:
客户端 (nuxt) 在 http://localhost:3000 上运行,客户端发送
请求http://localhost:8080。
服务器 (django) 正在 0.0.0.0:50051 上运行。
docker 也上线了
78496fef541f 5f9773709483 "/docker-entrypoint.…" 29 minutes
ago Up 29 minutes 0.0.0.0:8080->8080/tcp, :::8080-8080/tcp,
10000/tcp envoy
envoy.yaml 配置:
我配置envoy.yaml文件如下:
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: 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: 0.0.0.0
port_value: 50051
错误:
但是发生了以下错误,并且看起来,请求没有到达 Django 0.0.0.0:50051 服务器。
503 服务不可用
grpc-message:上游连接错误或断开/重置之前 标题。重置原因:连接失败,传输失败原因: 延迟连接错误:111
【问题讨论】:
-
0.0.0.0 不是有效的 IP 地址,因此您无法向其发送请求。 0.0.0.0 仅在绑定到端口时在服务器上才有意义,这意味着服务器将接受来自任何 IP 地址的连接。请改用localhost:8080。
-
@HansKilian 我根据in the document 所说的内容配置了文件。
-
好的。只是你写了(在你的帖子的第一行)你向0.0.0.0:8080 提出请求。您链接的文章说(在“编写客户端代码”下)您应该向localhost:8080 提出请求。
-
@HansKilian 你是对的。我做了这个更改,但仍然有同样的错误。
-
@HansKilian 我使用
nginx解决了这个问题。请看我的回答听听:stackoverflow.com/a/70417090/9422637
标签: docker grpc envoyproxy grpc-web