realpython / realpython/materials
Multiconnection server can't handle Connection Reset events
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Jupyter Notebook
- Star
- 5.2k
- Fork
- 5.3k
- Merge trung bình
- 4 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 10
Mô tả
It seems the Muli-connection server example doesn't properly handle the Connection Reset Error;
Traceback (most recent call last):
File "server.py", line 65, in <module>
service_connection(key, mask)
File "server.py", line 24, in service_connection
recv_data = sock.recv(1024) # Should be ready to read
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
This error occurs when, for example, the Windows Command Prompt running the client.py (connected to the server) is closed. In this case, a peer reset is sent to the server, but since the server can't handle it, it simply exits with the above error.
Is there any specific event to catch this error and avoid breaking the server?
Thanks
SS
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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với server.py, đặc biệt là service_connection ở dòng 24 và lệnh gọi event loop ở dòng 65. Tái hiện sự cố bằng cách đóng kết nối của Windows client, sau đó xác minh rằng server xử lý reset và tiếp tục phục vụ các kết nối khác thay vì thoát với ConnectionResetError.
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 55/100