Skip to content

fix: handle BYE in WaitAck state for server dialogs#108

Merged
yeoleobun merged 1 commit intorestsend:mainfrom
bevenky:fix/bye-in-waitack
Mar 30, 2026
Merged

fix: handle BYE in WaitAck state for server dialogs#108
yeoleobun merged 1 commit intorestsend:mainfrom
bevenky:fix/bye-in-waitack

Conversation

@bevenky
Copy link
Copy Markdown
Contributor

@bevenky bevenky commented Mar 29, 2026

Summary

SIP proxies may forward BYE to the UAS before the ACK for the 200 OK arrives, leaving the server dialog in WaitAck state. Previously BYE was silently ignored in this state, causing the application to not detect call termination until media timeout (typically 30s).

Now processes BYE in WaitAck state (same as Confirmed), transitioning the dialog to Terminated and responding with 200 OK.

Problem

  1. UAS sends 200 OK to INVITE, enters WaitAck state
  2. SIP proxy forwards BYE from caller before relaying ACK to UAS
  3. UAS receives BYE in WaitAck state — falls into catch-all match arm, BYE is ignored
  4. Dialog stays open, no CallTerminated event — application only detects hangup after 30s media timeout

This is common with B2BUA-style SIP proxies that handle ACK/BYE ordering independently on each leg.

Fix

Added rsip::Method::Bye handling in the non-confirmed state match arm of server_dialog.rs, calling handle_bye() which sends 200 OK and transitions to Terminated.

Per RFC 3261 Section 15.1.2, a UAS should process BYE even if the dialog is not yet confirmed.

Test plan

  • Existing tests pass
  • Verified with live SIP calls through B2BUA proxy — BYE detected immediately, 200 OK sent, dialog terminated

SIP proxies may forward BYE before the ACK for the 200 OK reaches
the UAS, leaving the server dialog in WaitAck state. Previously BYE
was silently ignored, causing the call to stay open until media timeout.

Now processes BYE in WaitAck state (same as Confirmed), transitioning
the dialog to Terminated and responding with 200 OK. This matches
RFC 3261 Section 15.1.2 behavior for early BYE processing.
@yeoleobun yeoleobun merged commit c9b2507 into restsend:main Mar 30, 2026
3 checks passed
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.

2 participants