python-hyper / python-hyper/h2
ProtocolError on receive_data after connection is closed
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1k
- 派生
- 187
- PR 合并指标
- 30 天内没有已合并 PR
描述
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.
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 h2/connection.py 中报告行附近的 receive_data、_receive_frame、_receive_ping_frame 和 process_input 开始。重现或建模连接达到 CLOSED 后收到 ping 的情况,然后检查现有的连接终止和缓冲帧测试。完成的标准是,剩余的已接收帧能够在不出现此 ProtocolError 的情况下得到处理,并且终止会按描述作为事件报告。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- networking
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100