python-hyper / python-hyper/h2

ProtocolError on receive_data after connection is closed

Abierto
#1,199 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
1k
Forks
187
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I am randomly getting this error on h2 3.1.1 (about once a week on a busy H2 client):

Traceback (most recent call last):
  File "site-packages/h2/connection.py", line 224, in process_input
    func, target_state = self._transitions[(self.state, input_)]
KeyError: (<ConnectionState.CLOSED: 3>, <ConnectionInputs.RECV_PING: 14>)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "nameclient.py", line 84, in recv_task
    for event in self.conn.receive_data(data):
  File "site-packages/h2/connection.py", line 1463, in receive_data
    events.extend(self._receive_frame(frame))
  File "site-packages/h2/connection.py", line 1486, in _receive_frame
    frames, events = self._frame_dispatch_table[frame.__class__](frame)
  File "site-packages/h2/connection.py", line 1725, in _receive_ping_frame
    ConnectionInputs.RECV_PING
  File "site-packages/h2/connection.py", line 229, in process_input
    "Invalid input %s in state %s" % (input_, old_state)
h2.exceptions.ProtocolError: Invalid input ConnectionInputs.RECV_PING in state ConnectionState.CLOSED

Unfortunately the code is somewhat complicated but I believe the connection closing logic to be correct. I never call close_connection and I quit receiving once ConnectionTerminated appears.

Possibly H2 is internally closing the connection due to ping timeout or other issue, and then throws me an error when the peer still sends something. Quite likely this actually happens when my laptop is in sleep, and H2 going ping-timeout meanwhile, with some data still in receive buffers. I would expect a ConnectionTerminated event in that case, after any remaining events are relayed, not an exception.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en h2/connection.py, en receive_data, _receive_frame, _receive_ping_frame y process_input, alrededor de las líneas indicadas. Reproduce o modela un ping que llegue después de que la conexión alcance CLOSED y revisa las pruebas existentes para la terminación de la conexión y los frames almacenados en búfer. Se considerará terminado cuando los frames recibidos restantes se gestionen sin este ProtocolError y la terminación se notifique como un evento, tal como se describe.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
networking
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.