Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

342
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda