This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Asyncio can't close sockets properly on Linux cause CLOSE_WAIT
Type: behavior Stage: resolved
Components: asyncio, SSL Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: Bob_2021, asvetlov, christian.heimes, ntc2, yselivanov
Priority: normal Keywords:

Created on 2021-02-10 01:42 by Bob_2021, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
server.py Bob_2021, 2021-02-10 02:25
Messages (3)
msg386753 - (view) Author: Bob (Bob_2021) Date: 2021-02-10 01:56
I wrote a simple proxy with Python3.8 and Asyncio, but I found it couldn't handle passive close correctly, a lot of CLOSE_WAIT sockets couldn't be released. I had trouble shot it for a long time with no progress.

netstat -anop tcp | grep CLOSE_WAIT

tcp6       0      0 64.XXX.XXX.XXX:80        113.58.229.12:46996     CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        222.137.35.237:54914    CLOSE_WAIT  10485/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        119.39.47.229:53882     CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        123.14.254.238:49262    CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        121.57.230.51:35036     CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        124.235.138.253:44882   CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        36.5.157.219:38006      CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
tcp6       0      0 64.XXX.XXX.XXX:80        150.255.5.121:39288     CLOSE_WAIT  10486/python3.8      off (0.00/0/0)
msg398697 - (view) Author: Nathan Collins (ntc2) * Date: 2021-08-01 13:44
What was the resolution for this issue? I'm experiencing asyncio.StreamReader.readline() hanging forever on a socket in CLOSE_WAIT state.
msg398733 - (view) Author: Nathan Collins (ntc2) * Date: 2021-08-02 07:59
I created a new issue for my bug here: https://bugs.python.org/issue44805
History
Date User Action Args
2022-04-11 14:59:41adminsetgithub: 87349
2021-08-02 07:59:27ntc2setmessages: + msg398733
2021-08-01 13:44:11ntc2setnosy: + ntc2
messages: + msg398697
2021-02-10 10:20:31Bob_2021setstatus: open -> closed
stage: resolved
2021-02-10 03:35:22Bob_2021setnosy: + christian.heimes

assignee: christian.heimes
components: + SSL
versions: + Python 3.7, Python 3.9, Python 3.10
2021-02-10 02:25:16Bob_2021setfiles: + server.py
2021-02-10 01:56:34Bob_2021setmessages: + msg386753
2021-02-10 01:42:49Bob_2021create