
Tenho um aplicativo criado como uma imagem Docker que funciona corretamente localmente, mas falha no Google Cloud Run com "erro de conexão upstream ou desconexão/redefinição antes dos cabeçalhos. motivo da redefinição: erro de protocolo"
O aplicativo está escutando em 0.0.0.0:8080 e não requer autenticação. Estou executando no Docker localmente com
docker run --rm --name myapp -p 8080:8080 myapp:1.0
Com curl localmente, recebo uma resposta bem-sucedida em/
$ curl -v localhost:8080
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Vary: Origin
< Date: Sat, 24 Jul 2021 13:54:11 GMT
< Content-Length: 2
<
* Connection #0 to host localhost left intact
OK* Closing connection 0
Implantei isso no Google Cloud Run como um serviço e, ao fazer a primeira solicitação, vejo a saída de log do meu aplicativo nos logs de execução na nuvem, mostrando que ele foi iniciado e está escutando na porta 8080.
No entanto, uma solicitação falha com
"upstream connect error or disconnect/reset before headers. reset reason: protocol error"
Saída completa de curl -vhttps://cloudrun-srv-stuff.a.run.app/é o seguinte
* Trying 216.239.36.53...
* TCP_NODELAY set
* Connected to cloudrun-srv-lz5wvvl32a-ez.a.run.app (216.239.36.53) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-ECDSA-CHACHA20-POLY1305
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google LLC; CN=*.a.run.app
* start date: Jun 28 01:08:46 2021 GMT
* expire date: Sep 20 01:08:45 2021 GMT
* subjectAltName: host "cloudrun-srv-stuff.a.run.app" matched cert's "*.a.run.app"
* issuer: C=US; O=Google Trust Services; CN=GTS CA 1O1
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f83b4810a00)
> GET / HTTP/2
> Host: cloudrun-srv-stuff.a.run.app
> User-Agent: curl/7.64.1
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
< HTTP/2 502
< content-length: 87
< content-type: text/plain
< date: Sat, 24 Jul 2021 13:58:13 GMT
< server: Google Frontend
< x-cloud-trace-context: 1370fab1a02839b367048f855593cbef/5890123523738625787;o=1
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
<
Quais são as próximas etapas para depurar isso?
Responder1
A resposta de John Hanely à minha pergunta identificou o problema.https://cloud.google.com/run/docs/configurando/http2#consoleme permitiu desabilitar o http/2 de ponta a ponta e isso resolveu o problema.