GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — asyncio proactor udp transport stops responding after send to port that isn't listening · Issue #91227 · python/cpython

asyncio proactor udp transport stops responding after send to port that isn't listening #91227

New issue
Copy link
New issue
Copy link
Closed
Closed
asyncio proactor udp transport stops responding after send to port that isn't listening#91227
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesOS-windowstopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

esoma
mannequin
opened on Mar 20, 2022
Issue body actions
BPO 47071
Nosy @pfmoore, @tjguk, @asvetlov, @zware, @1st1, @zooba, @esoma
PRs
  • gh-91227: Ignore ERROR_PORT_UNREACHABLE #32011
  • Files
  • udpbug2.py
  • windows_events.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 = None
    closed_at = None
    created_at = <Date 2022-03-20.14:58:17.671>
    labels = ['3.10', 'OS-windows', 'expert-asyncio']
    title = "asyncio proactor udp transport stops responding after send to port that isn't listening"
    updated_at = <Date 2022-03-20.15:48:54.679>
    user = 'https://github.com/esoma'

    bugs.python.org fields:

    activity = <Date 2022-03-20.15:48:54.679>
    actor = 'esoma'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Windows', 'asyncio']
    creation = <Date 2022-03-20.14:58:17.671>
    creator = 'esoma'
    dependencies = []
    files = ['50691', '50692']
    hgrepos = []
    issue_num = 47071
    keywords = ['patch']
    message_count = 4.0
    messages = ['415611', '415612', '415614', '415617']
    nosy_count = 7.0
    nosy_names = ['paul.moore', 'tim.golden', 'asvetlov', 'zach.ware', 'yselivanov', 'steve.dower', 'esoma']
    pr_nums = ['32011']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue47071'
    versions = ['Python 3.10']

    Linked PRs

    • [3.12] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (GH-32011) #117209
    • [3.11] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (GH-32011) #117210
    Reacted by R. and synodriver

    Activity

    Next
    1. esoma commented on Mar 20, 2022

      @esoma
      esomamannequin
      on Mar 20, 2022
      MannequinAuthor
      More actions

      Reproducer attached. Change USE_PROACTOR to False to use the SelectorEventLoop instead, which doesn't exhibit this behavior.

      The output on my machine when using the proactor loop is:

      datagram received b'ping 1'
      datagram received b'ping 2'
      

      And the selector loop (which is the behavior I would expect):

      datagram received b'ping 1'
      datagram received b'ping 2'
      datagram received b'ping 3'
      

      At a high level, after sending data to an address that isn't listening the asyncio protocol will no longer receive messages.

      Digging deeper, _ProactorDatagramTransport._loop_reading encounters the windows error 1234 (ERROR_PORT_UNREACHABLE) after the "bad send". It appears this a (undocumented/buggy?) behavior of WSARecvFrom where the next call to it after an unreachable WSASendTo in UDP mode will return the ICMP unreachable message. The actual error is returned from GetOverlappedResult.

      I've hacked together a fix that retries IocpProactor.recvfrom if the result is ERROR_PORT_UNREACHABLE. It fixes the issue for the reproducer and my actual use case, but it's probably not ideal. My solution for the moment is just to use the SelectorEventLoop instead.

      Reacted by R.
    2. esoma
      added
      3.10 (EOL)end of lifeend of life
      OS-windows
      topic-asyncio
      on Mar 20, 2022
    3. esoma commented on Mar 20, 2022

      @esoma
      esomamannequin
      on Mar 20, 2022
      MannequinAuthor
      More actions

      Uploading my hack to asyncio.windows_events.py -- this is based off 3.10.2's distribution.

    4. asvetlov commented on Mar 20, 2022

      @asvetlov
      asvetlov
      on Mar 20, 2022
      Contributor
      More actions

      Thanks for the report.
      Could you make a pull request?
      The whole attached windows_events.py is hard to analyze.

    5. esoma commented on Mar 20, 2022

      @esoma
      esomamannequin
      on Mar 20, 2022
      MannequinAuthor
      More actions

      Certainly: #32011

    6. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    7. ezio-melotti
      added this to asyncioon Jun 20, 2022
    8. ezio-melotti
      moved this to Todo in asyncioon Jul 17, 2022
    9. msoxzw commented on Jul 26, 2022

      @msoxzw
      msoxzw
      on Jul 26, 2022
      Contributor
      More actions

      As far as I know, there are several alternative solutions from open source projects:
      The Go programming language - https://github.com/golang/go/blob/ceefd3a37bb2a77b1e9a76fc74360c68ef16ddb8/src/internal/poll/fd_windows.go#L341-L352
      The libuv - https://github.com/libuv/libuv/blob/6c692ad1cbcc5083ec90954a4b091b660aedfc10/src/win/udp.c#L462-L486

    10. esoma commented on Jul 26, 2022

      @esoma
      esoma
      on Jul 26, 2022
      SponsorContributorAuthor
      More actions

      Looks like the libuv solution is similar to my PR -- just trying again.

      The go solution is much simpler though. I'll try that out.

    11. 12 remaining items

    12. jaycelq commented on Aug 24, 2023

      @jaycelq
      jaycelq
      on Aug 24, 2023
      More actions

      Any update on this issue?

      Reacted by Giovanni, Mikhail Razgovorov, synodriver, baterflyrity and Thomas Grainger
    13. gvanrossum
      added a commit that references this issue on Mar 23, 2024

      gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (#32011)

      f11d0d8
    14. gvanrossum
      closed this as completedon Mar 23, 2024
    15. github-project-automation
      moved this from Todo to Done in asyncioon Mar 23, 2024
    16. miss-islington
      added a commit that references this issue on Mar 25, 2024

      pythongh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (p…

      88e75de
    17. serhiy-storchaka
      added 3 commits that reference this issue on Mar 25, 2024

      [3.11] pythongh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recv…

      f9d904c

      [3.12] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (…

      bd2c60f

      [3.11] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (…

      6261322
    18. adorilson
      added a commit that references this issue on Mar 25, 2024

      pythongh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (p…

      1887240
    19. NGRsoftlab
      added 2 commits that reference this issue on Apr 2, 2024

      Squashed commit of the following:

      1b5fe4c

      Squashed commit of the following:

      a016a54
    20. diegorusso
      added a commit that references this issue on Apr 17, 2024

      pythongh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (p…

      076919f
    21. wcoldren
      added 2 commits that reference this issue on Jun 17, 2026

      New Game: Zillion (ArchipelagoMW#1081)

      6e2953e

      Zillion: map tracker in client (ArchipelagoMW#1136)

      2689735
    22. graingert
      added a commit that references this issue on Aug 31, 2026

      pythongh-127057: Re-arm proactor datagram read loop after a recoverab…

      3c2e804
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesOS-windowstopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      • asyncio
        Status
        Done
        Show more project fields

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.