Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

346
Visualizações
Python Quart/Hypercorn streamed response causing net::ERR_HTTP2_PROTOCOL_ERROR 200

I have a Quart app with which I stream a response back to the client. I am using asyncio.sleep to delay the response completion, if I set the delay to 59 seconds everythings works fine. The stream completes without any issue. If I increase the time to 120 seconds, the response appears to timeout. That is the first part of the stream is received by the client but after about 60 seconds the browser throws an error in Chrome it is: net::ERR_HTTP2_PROTOCOL_ERROR 200. Firefox throws a TypeError.

I am using Hypercorn with Nginx.

the hypercorn config.py file reads:

Shutdown_timeout = 123.0
ssl_handshake_timeout = 123.0
startup_timeout = 123.0

the relevant setting in nginx.conf:

location @proxy_to_app {
proxy_read_timout = 600s
}

I do not know how to solve this.

I figured out the source of the problem. It has nothing to do with Quart, Hypercorn or Nginx. The problem is with Cloudflare and http2, it is caused by a WriteTimeout. See this answer: What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

The question then is, how to change this in Cloudlfare.

I do not have Quart configured to work in http2, would that help?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The only solution I found was to break the sleep up and send interim data to the client in order to keep the connection alive.

async def async_generator():
      content_arr = [
          json.dumps({'first':'some data'}),
          json.dumps({'alive':''}),  #required to http2 connection alive
          json.dumps({'final' : 'final data'})
      ]
      for i,html in enumerate(content_arr):
          print(i)
          if i > 0:
              await asyncio.sleep(59)  #this delays sending the final data 118 seconds
          yield html.encode()
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda