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
dreimer1986 pushed a commit to dreimer1986/espcomponents that referenced this pull request Jul 28, 2026
…ssistant

Adds a "Decline calls during voice assistant" template switch
(entity_category: config, off by default). When on, an incoming SIP call
that arrives while the voice assistant is actively running an Assist turn
is auto-declined (603 Decline via sip_client.hangup, which already handles
that response for an unanswered SIP_INCOMING call) instead of ringing and
interrupting it. Default behavior (switch off) is unchanged: calls always
ring and take priority over the voice assistant.

This is the opt-in version of the reverse-direction suppression discussed
with Daniel Reimer on the Home Assistant community forum — made a switch
rather than the default since silently dropping calls isn't something
everyone wants.

Also updates the README's IPv6 note to reflect the socket-family fix
(eigger#282) rather than an unfixed known issue.

Verified: full esphome compile (esp32-s3, esphome==2026.7.2) of the merged
device_base.yaml + esp32.yaml + voice_pe.yaml package, no errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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