Skip to content

fix(sip): send 487 Request Terminated after OK (CANCEL) for pending INVITE #372

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mubashiroliyantakath
Copy link

When a CANCEL is received for an INVITE that hasn't been answered, the SIP gateway now correctly sends a 487 response to the original INVITE. This ensures proper SIP transaction termination and avoids issues where upstream proxies (e.g., Brekeke) keep the call in an INVITE state due to the missing final response.

closes #371

@mubashiroliyantakath mubashiroliyantakath requested a review from a team as a code owner May 22, 2025 01:50
@CLAassistant
Copy link

CLAassistant commented May 22, 2025

CLA assistant check
All committers have signed the CLA.

@dennwc dennwc self-assigned this May 22, 2025
Copy link
Contributor

@dennwc dennwc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for a PR! It looks good, except that inviteTx must be accessed under a mutex only.

Copy link

codecov bot commented May 22, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 62.56%. Comparing base (0460b40) to head (6463a66).
Report is 100 commits behind head on main.

Files with missing lines Patch % Lines
pkg/sip/inbound.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #372      +/-   ##
==========================================
- Coverage   65.25%   62.56%   -2.69%     
==========================================
  Files          51       32      -19     
  Lines        6588     6321     -267     
==========================================
- Hits         4299     3955     -344     
- Misses       1915     1992      +77     
  Partials      374      374              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mubashiroliyantakath
Copy link
Author

@dennwc thanks for the suggestion. Fixed it.

@zusrut
Copy link
Contributor

zusrut commented May 22, 2025

@mubashiroliyantakath you also need to check if the INVITE already got final response and in this case send BYE to terminate the session instead of 487.

@dennwc livekit/sip does not support sip signaling and requires deep changes. also i believe sipgo lib already cover some cases by its own - no need to implement it on such low level

@mubashiroliyantakath mubashiroliyantakath force-pushed the fix/sip-cancel-missing-487 branch 3 times, most recently from 5178728 to 17ddfb2 Compare May 26, 2025 01:09
@dennwc
Copy link
Contributor

dennwc commented May 26, 2025

@zusrut although you are right about sipgo supporting dialogs, we do use an older version of it. We need to migrate to a newer version before we can rely on it.

@alastor09
Copy link

@dennwc any other change you expect to be made before this can be merged? or any concerns?

…NVITE

When a CANCEL is received for an INVITE that hasn't been answered,
the SIP gateway now correctly sends a 487 response to the original
INVITE. This ensures proper SIP transaction termination and avoids
issues where upstream proxies (e.g., Brekeke) keep the call in
an INVITE state due to the missing final response.
@mubashiroliyantakath mubashiroliyantakath force-pushed the fix/sip-cancel-missing-487 branch from 17ddfb2 to 6463a66 Compare May 27, 2025 00:32
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.

487 not sent after CANCEL
5 participants