realpython / realpython/materials
Multiconnection server can't handle Connection Reset events
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 5.2k
- Forks
- 5.3k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 10
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with server.py, especially service_connection at line 24 and the event-loop call at line 65. Reproduce the issue by closing the Windows client connection, then verify that the server handles the reset and continues serving other connections instead of exiting with ConnectionResetError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100