René's URL Explorer Experiment


Title: asyncio proactor udp transport stops responding after send to port that isn't listening due to ConnectionResetError from WSARecvFrom · Issue #127057 · python/cpython · GitHub

Open Graph Title: asyncio proactor udp transport stops responding after send to port that isn't listening due to ConnectionResetError from WSARecvFrom · Issue #127057 · python/cpython

X Title: asyncio proactor udp transport stops responding after send to port that isn't listening due to ConnectionResetError from WSARecvFrom · Issue #127057 · python/cpython

Description: Bug report Bug description: I face a similar issue to #91227 , although instead of the error being thrown from the GetOverlappedResult, I get a ConnectionResetError thrown directly from the WSARecvFrom call. I am not quite sure what caus...

Open Graph Description: Bug report Bug description: I face a similar issue to #91227 , although instead of the error being thrown from the GetOverlappedResult, I get a ConnectionResetError thrown directly from the WSARecv...

X Description: Bug report Bug description: I face a similar issue to #91227 , although instead of the error being thrown from the GetOverlappedResult, I get a ConnectionResetError thrown directly from the WSARecv...

Opengraph URL: https://github.com/python/cpython/issues/127057

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"asyncio proactor udp transport stops responding after send to port that isn't listening due to ConnectionResetError from WSARecvFrom","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nI face a similar issue to #91227 , although instead of the error being thrown from the `GetOverlappedResult`, I get a `ConnectionResetError` thrown directly from the `WSARecvFrom` call.\r\n\r\nI am not quite sure what causes Windows to decide to throw the error from `WSARecvFrom` rather than from the respective `GetOverlappedResult`, but it appears to have something to do with timings and/or number of times an ICMP unreachable has been sent.\r\n\r\nI haven't put a log of effort to investigate, but I am able to reproduce it 100% of the times on my machine using this code:\r\n```python\r\nimport asyncio\r\nimport time\r\nimport socket\r\n\r\n\r\nclass Protocol(asyncio.DatagramProtocol):\r\n    def connection_made(self, transport):\r\n        self.transport = transport\r\n\r\n    def datagram_received(self, data, addr):\r\n        print(f'Received {data}')\r\n        time.sleep(1)\r\n        self.transport.sendto(b'test', ('127.0.0.1', 51346))\r\n\r\n\r\ndef send_data():\r\n    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\r\n    for i in range(100):\r\n        print(f'Sending {str(i)}')\r\n        s.sendto(str(i).encode(), ('127.0.0.1', 1337))\r\n        time.sleep(1)\r\n    s.close()\r\n\r\n\r\nasync def main():\r\n    loop = asyncio.get_running_loop()\r\n    transport, _ = await loop.create_datagram_endpoint(Protocol, local_addr=('127.0.0.1', 1337))\r\n    await asyncio.get_running_loop().run_in_executor(None, send_data)\r\n    transport.close()\r\n\r\n\r\nasyncio.run(main())\r\n```\r\nI usually get something like this output:\r\n```\r\nSending 0\r\nReceived b'0'\r\nSending 1\r\nReceived b'1'\r\nSending 2\r\nReceived b'2'\r\nSending 3\r\nSending 4\r\nSending 5\r\nSending 6\r\nSending 7\r\n```\r\n(i.e. after ~3 successful receives, the server stops receiving data).\r\n\r\nWhile debugging it, I was able to see that the call to `ov.WSARecvFrom(conn.fileno(), nbytes, flags)` in `windows_event.py` throws a `ConnectionResetError` at some point, which is caught in `_loop_writing` in `proactor_events.py`, causing it to basically stop its receiving loop.\r\n\r\nAn easy fix would be to retry the call to `ov.WSARecvFrom(conn.fileno(), nbytes, flags)` on `ConnectionResetError`. It seems to work after 2 retries, though I couldn't find a documentation that guarantees this behavior.\r\nSomething like this works for me:\r\n```diff\r\n    def recvfrom(self, conn, nbytes, flags=0):\r\n        self._register_with_iocp(conn)\r\n-        ov = _overlapped.Overlapped(NULL)\r\n        try:\r\n+            for _ in range(10):\r\n+                try:\r\n+                    ov = _overlapped.Overlapped(NULL)\r\n-            ov.WSARecvFrom(conn.fileno(), nbytes, flags)\r\n+                    ov.WSARecvFrom(conn.fileno(), nbytes, flags)\r\n+                    break\r\n+                except ConnectionResetError:\r\n+                    pass\r\n        except BrokenPipeError:\r\n            return self._result((b'', None))\r\n\r\n        return self._register(ov, conn, partial(self._finish_recvfrom,\r\n                                                empty_result=b''))\r\n```\r\n\r\nI could open a PR with such a change, though I am not sure how it should be tested, as I wasn't able to reproduce the issue without ugly and non-deterministic sleeps.\r\n\r\n### CPython versions tested on:\r\n\r\n3.13\r\n\r\n### Operating systems tested on:\r\n\r\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156726\n* gh-156976\n* gh-156977\n* gh-156978\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/bugale","@type":"Person","name":"bugale"},"datePublished":"2024-11-20T13:09:39Z","url":"https://github.com/python/cpython/issues/127057"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:2d5d417d-a710-450e-000a-64df72423377
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA8E8:380435:3568C2:437224:6B01FA5A
html-safe-nonce0bc179cb6847615e8e9fa04144baa64a91f64b029df5a683a5692d1a9467c594
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEU4OjM4MDQzNTozNTY4QzI6NDM3MjI0OjZCMDFGQTVBIiwidmlzaXRvcl9pZCI6IjQ3ODUyODI0MTI1NTE4NDk4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac43a93c907b69a22f5248cbaf54bebb2571bd03b445038b9859e8bfb1691665e1
hovercard-subject-tagissue:2675803049
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/127057/issue_layout
twitter:imagehttps://opengraph.githubassets.com/1a2e2ba57cbd4418531e767255d495df9906740de19e3d3a227b5b6fcd0c9814/python/cpython/issues/127057
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/1a2e2ba57cbd4418531e767255d495df9906740de19e3d3a227b5b6fcd0c9814/python/cpython/issues/127057
og:image:altBug report Bug description: I face a similar issue to #91227 , although instead of the error being thrown from the GetOverlappedResult, I get a ConnectionResetError thrown directly from the WSARecv...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebugale
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/127057#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F127057
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F127057
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/127057
Reloadhttps://github.com/python/cpython/issues/127057
Reloadhttps://github.com/python/cpython/issues/127057
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/127057
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/127057
asyncio proactor udp transport stops responding after send to port that isn't listening due to ConnectionResetError from WSARecvFromhttps://github.com/python/cpython/issues/127057#top
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/bugale
bugalehttps://github.com/bugale
on Nov 20, 2024https://github.com/python/cpython/issues/127057#issue-2675803049
#91227https://github.com/python/cpython/issues/91227
gh-127057: Re-arm proactor datagram read loop after a recoverable OSError #156726https://github.com/python/cpython/pull/156726
[3.15] gh-127057: reschedule proactor datagram read loop after ConnectionResetError (GH-156726) #156976https://github.com/python/cpython/pull/156976
[3.14] gh-127057: reschedule proactor datagram read loop after ConnectionResetError (GH-156726) #156977https://github.com/python/cpython/pull/156977
[3.13] gh-127057: reschedule proactor datagram read loop after ConnectionResetError (GH-156726) #156978https://github.com/python/cpython/pull/156978
bugalehttps://github.com/bugale
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Nov 20, 2024https://github.com/python/cpython/issues/127057#event-15366992793
AlexWaygoodhttps://github.com/AlexWaygood
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
on Nov 20, 2024https://github.com/python/cpython/issues/127057#event-15369050573
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Nov 20, 2024https://github.com/python/cpython/issues/127057#event-15369051841
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Nov 20, 2024https://github.com/python/cpython/issues/127057
graingerthttps://github.com/graingert
on Aug 31, 2026https://github.com/python/cpython/issues/127057#event-30292546685
pythongh-127057: Re-arm proactor datagram read loop after a recoverab…https://github.com/graingert/cpython/commit/3c2e804ffb4a79e6037568eb54c76a62bd65ec5b
pythongh-127057https://github.com/python/cpython/issues/127057
3c2e804https://github.com/graingert/cpython/commit/3c2e804ffb4a79e6037568eb54c76a62bd65ec5b
pythongh-127057: Re-arm proactor datagram read loop after a recoverab…https://github.com/graingert/cpython/commit/e45ba5a9f14097e3e7e0671ff110f50a0bb89321
pythongh-127057https://github.com/python/cpython/issues/127057
e45ba5ahttps://github.com/graingert/cpython/commit/e45ba5a9f14097e3e7e0671ff110f50a0bb89321
pythongh-127057: Re-arm proactor datagram read loop after a recoverab…https://github.com/graingert/cpython/commit/eb0959553670216e72a12b94bd3cd36f1a3f5a19
pythongh-127057https://github.com/python/cpython/issues/127057
eb09595https://github.com/graingert/cpython/commit/eb0959553670216e72a12b94bd3cd36f1a3f5a19
kumaraditya303https://github.com/kumaraditya303
on Sep 5, 2026https://github.com/python/cpython/issues/127057#event-30600390297
pythongh-127057: Fix proactor datagram transport going silent after C…https://github.com/kumaraditya303/cpython/commit/d2ccd458c2d6ae171a5c302cf931d81c947b335a
pythongh-127057https://github.com/python/cpython/issues/127057
d2ccd45https://github.com/kumaraditya303/cpython/commit/d2ccd458c2d6ae171a5c302cf931d81c947b335a
gh-127057: reschedule proactor datagram read loop after ConnectionRes…https://github.com/python/cpython/commit/0ea2971c6eeaaed3429b5b655b77afe24fa798a8
gh-127057https://github.com/python/cpython/issues/127057
0ea2971https://github.com/python/cpython/commit/0ea2971c6eeaaed3429b5b655b77afe24fa798a8
kumaraditya303https://github.com/kumaraditya303
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Sep 5, 2026https://github.com/python/cpython/issues/127057#event-30604688578
github-project-automationhttps://github.com/apps/github-project-automation
asynciohttps://github.com/orgs/python/projects/29
on Sep 5, 2026https://github.com/python/cpython/issues/127057
kumaraditya303https://github.com/kumaraditya303
on Sep 5, 2026https://github.com/python/cpython/issues/127057#event-30607568760
[3.14] gh-127057: reschedule proactor datagram read loop after Connec…https://github.com/python/cpython/commit/9e97d9ff7d9d2874403f746ccf308a5e758dc8de
gh-127057https://github.com/python/cpython/issues/127057
9e97d9fhttps://github.com/python/cpython/commit/9e97d9ff7d9d2874403f746ccf308a5e758dc8de
[3.13] gh-127057: reschedule proactor datagram read loop after Connec…https://github.com/python/cpython/commit/ffa12f7437e2de6621db0b5c30b3bb0759d0a689
gh-127057https://github.com/python/cpython/issues/127057
ffa12f7https://github.com/python/cpython/commit/ffa12f7437e2de6621db0b5c30b3bb0759d0a689
hugovkhttps://github.com/hugovk
on Sep 5, 2026https://github.com/python/cpython/issues/127057#event-30610409556
[3.15] gh-127057: reschedule proactor datagram read loop after Connec…https://github.com/python/cpython/commit/43877447ef5fc3280f73079467cb5f77011ae416
gh-127057https://github.com/python/cpython/issues/127057
4387744https://github.com/python/cpython/commit/43877447ef5fc3280f73079467cb5f77011ae416
clin1234https://github.com/clin1234
on Sep 12, 2026https://github.com/python/cpython/issues/127057#event-31023917376
pythongh-127057: reschedule proactor datagram read loop after Connect…https://github.com/clin1234/cpython/commit/2150ba8396b4d6254e87d149e2d740ebeb504317
pythongh-127057https://github.com/python/cpython/issues/127057
2150ba8https://github.com/clin1234/cpython/commit/2150ba8396b4d6254e87d149e2d740ebeb504317
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/127057
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/127057
topic-asynciohttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-asyncio%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
asynciohttps://github.com/orgs/python/projects/29
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.