Title: Using IPVersion.All leads to OSError: [Errno 101] Network is unreachable logged · Issue #1357 · python-zeroconf/python-zeroconf · GitHub
Open Graph Title: Using IPVersion.All leads to OSError: [Errno 101] Network is unreachable logged · Issue #1357 · python-zeroconf/python-zeroconf
X Title: Using IPVersion.All leads to OSError: [Errno 101] Network is unreachable logged · Issue #1357 · python-zeroconf/python-zeroconf
Description: When using AsyncZeroconf(ip_version=IPVersion.All) this can lead to the following warning being logged: WARNING Error with socket 66 (('::1', 5353, 0, 0))): [Errno 101] Network is unreachable Traceback (most recent call last): File "/usr...
Open Graph Description: When using AsyncZeroconf(ip_version=IPVersion.All) this can lead to the following warning being logged: WARNING Error with socket 66 (('::1', 5353, 0, 0))): [Errno 101] Network is unreachable Trace...
X Description: When using AsyncZeroconf(ip_version=IPVersion.All) this can lead to the following warning being logged: WARNING Error with socket 66 (('::1', 5353, 0, 0))): [Errno 101] Network is unreachab...
Opengraph URL: https://github.com/python-zeroconf/python-zeroconf/issues/1357
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using IPVersion.All leads to OSError: [Errno 101] Network is unreachable logged","articleBody":"When using `AsyncZeroconf(ip_version=IPVersion.All)` this can lead to the following warning being logged:\r\n\r\n```\r\nWARNING Error with socket 66 (('::1', 5353, 0, 0))): [Errno 101] Network is unreachable\r\nTraceback (most recent call last):\r\n File \"/usr/local/lib/python3.11/asyncio/selector_events.py\", line 1196, in sendto\r\n self._sock.sendto(data, addr)\r\nOSError: [Errno 101] Network is unreachable\r\n```\r\n\r\nIt seems that listening to the IPv6 loopback on it's own isn't problematic, but when trying to send to that socket, it leads to the above error. The problematic socket is created via `get_all_addresses_v6()`, which returns the loopback interface with the `::1` address (the full tuple being `(('::1', 0, 0), 1)`).\r\n\r\nThis then leads to a socket with the follow options created:\r\n```\r\nimport socket\r\nimport struct\r\ns = socket.socket(family=socket.AF_INET6, type=socket.SOCK_DGRAM)\r\ns.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False)\r\ns.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\r\ns.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)\r\ns.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_HOPS, 255)\r\ns.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_LOOP, True)\r\ns.bind(('::2', 5353, 0, 0))\r\ns.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_MULTICAST_IF, struct.pack('@I', 1))\r\n```\r\n\r\nWhen this socket then is used, the stack trace appears:\r\n```\r\ns.sendto(b\"Hello\", ('ff02::fb', 5353, 0, 0))\r\n```\r\n```\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\nOSError: [Errno 101] Network is unreachable\r\n```\r\n\r\nThe relevant option seem to be the IPv6 specific binding to the interface index `IPV6_MULTICAST_IF`, in this case 1 for the loopback interface.\r\n\r\n\r\n\r\n\r\n\r\n\r\n","author":{"url":"https://github.com/agners","@type":"Person","name":"agners"},"datePublished":"2024-02-07T18:46:14.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/1357/python-zeroconf/issues/1357"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:902ff6c0-6af2-f4e7-1ad7-3109ef0eee83 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CA26:2E37C2:3445926:4659062:6971E934 |
| html-safe-nonce | 49d1aec6b7f17c343950cb5ce8b3a42355b3a92bcb84a1ed991322d2597758c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTI2OjJFMzdDMjozNDQ1OTI2OjQ2NTkwNjI6Njk3MUU5MzQiLCJ2aXNpdG9yX2lkIjoiMjIzMzYwOTY3NTQ3MzAyMTIzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bc6937e8993b71290c59b31b848fe57ae33ca85f17cbb5f29839199c4161bfb7 |
| hovercard-subject-tag | issue:2123656514 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-zeroconf/python-zeroconf/1357/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef6ff04567d9be0ebcc84bc218994bf6c56a61446c30a5cc84ba006b580aaa5c/python-zeroconf/python-zeroconf/issues/1357 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef6ff04567d9be0ebcc84bc218994bf6c56a61446c30a5cc84ba006b580aaa5c/python-zeroconf/python-zeroconf/issues/1357 |
| og:image:alt | When using AsyncZeroconf(ip_version=IPVersion.All) this can lead to the following warning being logged: WARNING Error with socket 66 (('::1', 5353, 0, 0))): [Errno 101] Network is unreachable Trace... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | agners |
| hostname | github.com |
| expected-hostname | github.com |
| None | 683712716975b3393656edf09255a1d488d0e68ab7b9ac97e40ecf40036f696c |
| turbo-cache-control | no-preview |
| go-import | github.com/python-zeroconf/python-zeroconf git https://github.com/python-zeroconf/python-zeroconf.git |
| octolytics-dimension-user_id | 120192235 |
| octolytics-dimension-user_login | python-zeroconf |
| octolytics-dimension-repository_id | 21548731 |
| octolytics-dimension-repository_nwo | python-zeroconf/python-zeroconf |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 21548731 |
| octolytics-dimension-repository_network_root_nwo | python-zeroconf/python-zeroconf |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ed99da4e2de688dd1056894c1eccd4c82c6bbbfe |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width