sip 이용해서 전화를 걸었는데 상대가 끊었을 때를 알 수있어?
# ask-ai
t
sip 이용해서 전화를 걸었는데 상대가 끊었을 때를 알 수있어?
t
Thanks for reaching out, 유용현. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you detect when a call is ended by the other party using SIP in LiveKit, you can keep an eye on the SIP participant's attributes, especially the
sip.callStatus
. When this status updates to
hangup
, it means the call was ended by the other party. Here’s a simple example in Python that might make things clearer:
Copy code
def on_participant_attributes_changed_handler(changed_attributes: dict, participant: rtc.Participant):
    if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
        if 'sip.callStatus' in changed_attributes:
            call_status = changed_attributes['sip.callStatus']
            if call_status == 'hangup':
                print("Call has been ended by the other party")

ctx.room.on("participant_attributes_changed", on_participant_attributes_changed_handler)
Additionally, you can take advantage of system-level analytics events like
SIP_CALL_ENDED
or use the
OnSessionEnd
callback in a custom SIP service to handle this programmatically. If you’d like, I’m here to help you walk through the implementation or answer any other questions you might have! Sources: SIP participant | LiveKit docs | pkg/sip/inbound.go | livekit-protocol/livekit/protocol/analytics.pyi | telephony/sip_lifecycle.py
t
상대가 받고나서 끊은거잖아 그냥 받지도않고 끊는거
t
To help you detect when a SIP call is rejected or not answered, here are a few friendly methods you can try: 1. Keep an eye on `sip.callStatus`: You can listen for changes in the participant's attributes. If the call gets rejected or isn’t answered, the participant will disconnect, and you’ll notice that
sip.callStatus
doesn’t reach
active
. 2. Check the Disconnect Reason: When the SIP participant disconnects, take a look at the reason behind it. For example: ◦ `USER_UNAVAILABLE`: This means the callee didn’t answer within the timeout period. ◦ `USER_REJECTED`: This indicates the callee explicitly rejected the call. 1. Try using `wait_until_answered`: When you create a SIP participant, you can set
wait_until_answered=true
. If the call isn’t answered or gets rejected, the API will give you an error with all the details you need. If you’d like, I’m here to help you implement any of these methods—just let me know! Sources: Making outbound calls | LiveKit docs | SIP participant | LiveKit docs | livekit-ffi/protocol/participant.proto | Agents telephony integration | LiveKit docs | protobufs/livekit_sip.proto
t
Error creating SIP participant: Protocol message CreateSIPParticipantRequest has no "wait_to_welp" field.
t
It looks like the error is happening because
wait_to_welp
isn’t a valid field in the
CreateSIPParticipantRequest
. The right field name you want to use is actually
wait_until_answered
. Here’s a simple way to fix it:
Copy code
request = CreateSIPParticipantRequest(
    sip_trunk_id="<trunk_id>",
    sip_call_to="<phone_number>",
    room_name="my-sip-room",
    participant_identity="sip-test",
    wait_until_answered=True
)
Just swap out
wait_to_welp
for
wait_until_answered
in your request setup. If you have any questions or need a hand with anything else, feel free to reach out—I’m here to help! Sources: SIP APIs | LiveKit docs | livekit-protocol/livekit/protocol/sip.py | Make outbound calls | LiveKit docs | agent.py | livekit/livekit_sip.pb.go