fix(sip_client): pick UDP socket family from the target address, not … - #282
Merged
Conversation
…enable_ipv6 socket::socket_ip() creates an AF_INET6-only socket whenever ESPHome's global network: enable_ipv6 is on (or the ESP-IDF/lwIP sdkconfig default has it on), regardless of what address the caller is about to talk to. Both the SIP signaling socket (sip_client.cpp) and the RTP media socket (rtp_session.cpp) used it unconditionally, so an IPv4 registrar/PBX (the common case, e.g. a router's built-in SIP server) got connect()/send() against a family-mismatched socket and registration silently never completed — this is the known "keep IPv6 disabled" issue noted in the component README. Fix: derive the socket's family from the actual destination — set_sockaddr()'s resulting sockaddr's ss_family for the SIP socket, and the already-known remote peer's ss_family (set via set_remote() before start()) for the RTP socket — instead of the global enable_ipv6 toggle. The new AF_INET6 code path in rtp_session.cpp is guarded by USE_NETWORK_IPV6, since struct sockaddr_in6 isn't even declared when IPv6 support is compiled out (the common/recommended case per the README). Verified compiling clean against real esphome==2026.6.5 and esphome==2026.7.2, both with enable_ipv6 left at default (off) and explicitly set to true. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…enable_ipv6
socket::socket_ip() creates an AF_INET6-only socket whenever ESPHome's global network: enable_ipv6 is on (or the ESP-IDF/lwIP sdkconfig default has it on), regardless of what address the caller is about to talk to. Both the SIP signaling socket (sip_client.cpp) and the RTP media socket (rtp_session.cpp) used it unconditionally, so an IPv4 registrar/PBX (the common case, e.g. a router's built-in SIP server) got connect()/send() against a family-mismatched socket and registration silently never completed — this is the known "keep IPv6 disabled" issue noted in the component README.
Fix: derive the socket's family from the actual destination — set_sockaddr()'s resulting sockaddr's ss_family for the SIP socket, and the already-known remote peer's ss_family (set via set_remote() before start()) for the RTP socket — instead of the global enable_ipv6 toggle. The new AF_INET6 code path in rtp_session.cpp is guarded by USE_NETWORK_IPV6, since struct sockaddr_in6 isn't even declared when IPv6 support is compiled out (the common/recommended case per the README).
Verified compiling clean against real esphome==2026.6.5 and esphome==2026.7.2, both with enable_ipv6 left at default (off) and explicitly set to true.