python-hyper / python-hyper/h2

ProtocolError on receive_data after connection is closed

Đang mở
#1,199 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
Python
Star
1k
Fork
187
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu trong h2/connection.py tại receive_data, _receive_frame, _receive_ping_frame và process_input, xung quanh các dòng được báo cáo. Tái hiện hoặc mô hình hóa trường hợp một ping đến sau khi kết nối đạt CLOSED, sau đó kiểm tra các test hiện có cho việc kết thúc kết nối và các frame được đệm. Hoàn tất khi các frame còn lại đã nhận được xử lý mà không gặp ProtocolError này và việc kết thúc được báo cáo dưới dạng một sự kiện như mô tả.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
networking
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.