Skip to content

outbound call status error #366

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ilhansevval opened this issue Mar 11, 2025 · 3 comments
Open

outbound call status error #366

ilhansevval opened this issue Mar 11, 2025 · 3 comments

Comments

@ilhansevval
Copy link

Dear Support Team,
I'm writing to report an issue with the call status monitoring functionality. We've identified a problem where the call status continues to show as "active" even after the call has been terminated from the other end.
Issue Details:
During outbound calls, we periodically check the call status
When the status changes to "active", we initiate call recording as expected
However, even after the call is terminated, the status continues to return "active"
This causes the recording to continue unnecessarily
Log Evidence:

10:25:08,079 [INFO] Periodic check (1/12): Call status = ringing
10:25:13,079 [INFO] Periodic check (2/12): Call status = ringing
10:25:18,080 [INFO] Periodic check (3/12): Call status = active
10:25:18,080 [INFO] ⏰ Periodic check found active call, starting recording

Code Example:

async def check_and_start_recording_if_needed(recorder, participant: rtc.RemoteParticipant, delay_seconds):
    """
    Check if recording has started after a specified delay, 
    and start it only if certain conditions are met.
    """
    await asyncio.sleep(delay_seconds)
    
    logger.info("Checking if recording has started...")
    
    # Check if recording has already started
    if not recorder.is_recording():
        logger.info("Recording not started after delay, checking SIP call status")
        
        # Check SIP status
        if hasattr(participant, 'attributes'):
            call_status = participant.attributes.get("sip.callStatus")
            logger.info(f"Current SIP call status: {call_status}")
            
            if call_status == "active":
                logger.info("SIP call is active, starting recording")
                await recorder.force_start_recording()
            elif call_status == "ringing":
                logger.info("SIP call is still ringing, will wait for active status")
                # Set up a task to check again after a few seconds
                asyncio.create_task(recheck_call_status(recorder, participant, 5))
            else:
                logger.warning(f"SIP call status is '{call_status}', not starting recording yet")
        else:
            logger.warning("Participant has no attributes, cannot determine call status")

async def recheck_call_status(recorder, participant, delay_seconds):
    """
    Recheck the call status after a delay and potentially start recording.
    """
    await asyncio.sleep(delay_seconds)
    
    if hasattr(participant, 'attributes'):
        call_status = participant.attributes.get("sip.callStatus")
        logger.info(f"Rechecking SIP call status: {call_status}")
        
        if call_status == "active" and not recorder.is_recording():
            logger.info("SIP call became active on recheck, starting recording")
            await recorder.force_start_recording()
        elif call_status == "ringing" and not recorder.is_recording():
            # Still ringing, check again later
            asyncio.create_task(recheck_call_status(recorder, participant, 5))
    else:
        logger.warning("Participant has no attributes on recheck, cannot determine call status")

This behavior leads to extended recordings and potential resource inefficiency. We would appreciate your assistance in resolving this issue so that call status accurately reflects when a call has ended.
Please let me know if you need any additional information or logs to help diagnose this problem.
Thank you for your assistance.
Regards,

Şevval İLHAN

@divy-vozzo
Copy link

same issue i am facing since we moved to agent 1.0, if was working fine earlier with same sip settings.

@dennwc dennwc transferred this issue from livekit/livekit May 20, 2025
@dennwc
Copy link
Contributor

dennwc commented May 20, 2025

The OP issue is related to us not seeing BYE from Plivo. Investigating with their team.

@yepher
Copy link

yepher commented May 20, 2025

I think this ticket maybe similar or same as:
#316

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

No branches or pull requests

4 participants