Skip to content

fix(sip_client): pick UDP socket family from the target address, not … - #282

Merged
eigger merged 1 commit into
masterfrom
fix/sip-client-socket-address-family
Jul 27, 2026
Merged

fix(sip_client): pick UDP socket family from the target address, not …#282
eigger merged 1 commit into
masterfrom
fix/sip-client-socket-address-family

Conversation

@eigger

@eigger eigger commented Jul 27, 2026

Copy link
Copy Markdown
Owner

…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.

…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>
@eigger
eigger merged commit 8a957a8 into master Jul 27, 2026
3 checks passed
@eigger
eigger deleted the fix/sip-client-socket-address-family branch July 27, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant