[英]Unable to call grpc server hosted behind traefik reverse proxy
我面臨一個奇怪的問題,我無法調用托管在 traefik 代理后面的 gRPC 服務器,該服務器在具有 http/2 的容器中運行,並且來自 asp.net 5 應用程序的自定義子域也托管在另一個容器中,該容器映射了另一個域名。 我收到以下錯誤:
Status(StatusCode="Unavailable", Detail="Error starting gRPC call. HttpRequestException: Connection timed out (subdomain:443) SocketException: Connection timed out", DebugException="System.Net.Http.HttpRequestException: Connection timed out (subdomain:443)
當我嘗試從開發 docker-compose 調用相同的托管 gRPC 服務器時,它工作正常。 我嘗試了不同的 Uri 地址組合(方案、主機和端口),這兩種方法都是 Microsoft 在其網站上提供的調用 gRPC 服務器(控制台和 DI)的方法,我什至嘗試將以下 AppContext 設置為 true,但看起來像托管應用程序無法啟動通話。
System.AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport");
grpc服務器的docker-compose為:
version: '3'
networks:
web:
external: true
internal:
external: false
services:
grpcservice:
image: <imagename:tag>
labels:
- traefik.protocol=h2c
- traefik.backend=grpcservice
- traefik.frontend.rule=Host:<subdomain>
- traefik.docker.network=web
- traefik.port=9001
networks:
- internal
- web
environment:
- ASPNETCORE_ENVIRONMENT=Production
- FilePath__FPath=<some file>
- Auth0__Domain=<Domain>
- Auth0__Audience=<Audience>
restart: on-failure
Asp.net 5 App的docker-compose是:
version: '3'
networks:
web:
external: true
internal:
external: false
services:
aspapp:
image: <imagename:tag>
labels:
- traefik.backend=aspapp
- traefik.frontend.rule=Host:<domain>
- traefik.docker.network=web
- traefik.port=9000
networks:
- internal
- web
environment:
- ASPNETCORE_ENVIRONMENT=Production
<Auth0 envoirnment vairables>
restart: on-failure
Traefik.toml 配置為:
defaultEntryPoints = ["http", "https"]
[entryPoints]
[entryPoints.dashboard]
address = ":8080"
[entryPoints.dashboard.auth]
[entryPoints.dashboard.auth.basic]
users = ["Auth credentials"]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[api]
entrypoint="dashboard"
[acme]
email = "email"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"
logLevel = "DEBUG"
[traefikLog]
filePath = "traefik.log"
format = "json"
[docker]
domain = "domain"
watch = true
network = "web"
當我從托管應用程序和本地開發容器訪問同一個 gRPC 服務器時,我無法理解為什么會出現行為差異,我該如何解決?
這只是一個愚蠢的防火牆問題,阻止了容器 @ 443
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.