Anyone any idea why SIP authentication from Twilio...
# telephony
e
Anyone any idea why SIP authentication from Twilio works most of the time, but not all the time? PCAP of random failure:
Copy code
14:40:31.310595 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: INVITE <sip:24b873a3-ab48-4f0a-9c8d-7590ca23aacb@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
14:40:31.312208 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 100 Processing
14:40:31.351975 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 407 Unauthorized
14:40:31.352024 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: ACK <sip:24b873a3-ab48-4f0a-9c8d-7590ca23aacb@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
14:40:31.354423 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: INVITE <sip:24b873a3-ab48-4f0a-9c8d-7590ca23aacb@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
14:40:31.356091 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 100 Processing
14:40:31.358843 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 401 Bad credentials
14:40:31.358943 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: ACK <sip:24b873a3-ab48-4f0a-9c8d-7590ca23aacb@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
PCAP of it succeeding a few minutes later without any configuration changes:
Copy code
14:43:24.073062 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: INVITE <sip:302365fe-f58f-4b01-8f34-a735f919d486@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
14:43:24.074502 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 100 Processing
14:43:24.118803 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 407 Unauthorized
14:43:24.118853 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: ACK <sip:302365fe-f58f-4b01-8f34-a735f919d486@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
14:43:24.121232 IP ec2-54-172-60-2.compute-1.amazonaws.com.sip > 161.115.178.89.sip: SIP: INVITE <sip:302365fe-f58f-4b01-8f34-a735f919d486@4wxwgg2qj6t.sip>.livekit.cloud SIP/2.0
14:43:24.122531 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 100 Processing
14:43:24.180973 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 180 Ringing
14:43:24.287897 IP 161.115.178.89.sip > ec2-54-172-60-2.compute-1.amazonaws.com.sip: SIP: SIP/2.0 200 OK
Twiml used:
Copy code
<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Dial answerOnBridge="true" action="/twilio/handle-teammate-agent-call-status?recording_id=302365fe-f58f-4b01-8f34-a735f919d486" method="POST" timeout="10" record="record-from-ringing">
        <Sip username="top-secret" password="top-secret"><sip:302365fe-f58f-4b01-8f34-a735f919d486@4wxwgg2qj6t.sip>.livekit.cloud</Sip>
    </Dial>
</Response>
r
I would say grab the PCAP of a failure and verify the HMAC. If it is correct there is an issue with Twilio.
👀 1
e
If it is correct there is an issue with Twilio.
Can you clarify? Twilio is forwarding an inbound call to LiveKit. If the HMAC response is correctly calculated by Twilio, then there's an issue with LiveKit, right?
r
yes, sorry I thought it was other direction
👍 1
But check the HMAC
e
I manually computed the
Proxy-Authorization
response for a successful call and a failure call, and came up with the same result Twilio did in both cases. But one was rejected by LiveKit with a 401 response for no apparent reason.
r
you have a PCAP for a failed call?
e
call-log-CA68a39d53a2e22a9a8aee85e08ff7765b.pcap
r
The 401 is for SIP right and not the websocket
e
yes, SIP
r
Why is the
to
in that PCAP a UUID?
that should be a E.164 phone number. Right?
e
The
to
is the name of the LiveKit room that we want to join, and that room name happens to be a UUID (corresponding to an internal identifier). We have "Callee" dispatch rule set up to make this work.
r
The error I see in our log for auth fail is
Copy code
No challenge state found for authentication attempt
11/4/2025, 4:40:31 PM
Error: missing challenge state
I will need to look into this more.
e
Thank you, appreciate it!
r
Team took a look at this last night and has identified the issue and is working on a fix for it. Sorry for the trouble
e
Great, love to hear it! Thank you for escalating it!