Skip to content

Asyncio can't close sockets properly on Linux cause CLOSE_WAIT #87349

Description

@Bob2021
mannequin
BPO 43183
Nosy @tiran, @ntc2, @asvetlov, @1st1
Files
  • server.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/tiran'
    closed_at = <Date 2021-02-10.10:20:31.973>
    created_at = <Date 2021-02-10.01:42:49.923>
    labels = ['expert-SSL', 'type-bug', '3.8', '3.9', '3.10', '3.7', 'expert-asyncio']
    title = "Asyncio can't close sockets properly on Linux cause CLOSE_WAIT"
    updated_at = <Date 2021-08-02.07:59:27.063>
    user = 'https://bugs.python.org/Bob2021'

    bugs.python.org fields:

    activity = <Date 2021-08-02.07:59:27.063>
    actor = 'ntc2'
    assignee = 'christian.heimes'
    closed = True
    closed_date = <Date 2021-02-10.10:20:31.973>
    closer = 'Bob_2021'
    components = ['asyncio', 'SSL']
    creation = <Date 2021-02-10.01:42:49.923>
    creator = 'Bob_2021'
    dependencies = []
    files = ['49799']
    hgrepos = []
    issue_num = 43183
    keywords = []
    message_count = 3.0
    messages = ['386753', '398697', '398733']
    nosy_count = 5.0
    nosy_names = ['christian.heimes', 'ntc2', 'asvetlov', 'yselivanov', 'Bob_2021']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue43183'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

    Activity

    1. Bob2021 commented on Feb 10, 2021

      Bob2021mannequin
      MannequinAuthor

      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)

    2. ntc2 commented on Aug 1, 2021

      ntc2mannequin
      Mannequin

      What was the resolution for this issue? I'm experiencing asyncio.StreamReader.readline() hanging forever on a socket in CLOSE_WAIT state.

    3. ntc2 commented on Aug 2, 2021

      ntc2mannequin
      Mannequin

      I created a new issue for my bug here: https://bugs.python.org/issue44805

    4. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions