realpython / realpython/materials

Multiconnection server can't handle Connection Reset events

オープン
#210 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Jupyter Notebook
スター
5.2k
フォーク
5.3k
平均マージ
4日 10時間
マージ済み PR(30日)
10

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

server.pyから始め、特に24行目のservice_connectionと65行目のイベントループの呼び出しを確認してください。Windowsクライアントの接続を閉じて問題を再現し、その後、サーバーがリセットを処理し、ConnectionResetErrorで終了せずに他の接続の処理を継続することを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。