Skip to content

Fix gen_call_id producing the identical Call-ID across process restarts - #318

Open
hainesdev wants to merge 1 commit into
tayler6000:masterfrom
hainesdev:bugfix/Issue-316
Open

Fix gen_call_id producing the identical Call-ID across process restarts#318
hainesdev wants to merge 1 commit into
tayler6000:masterfrom
hainesdev:bugfix/Issue-316

Conversation

@hainesdev

Copy link
Copy Markdown

Fixes #316

gen_call_id() derived the Call-ID from hashlib.sha256(str(self.callID.next())), where self.callID is a Counter that restarts at the same initial value every time a SIPClient is constructed. Any short-lived process (register, place one call, exit) generates the identical Call-ID on every run.

If the server still has any memory of a dialog under that Call-ID from a previous run, the new INVITE gets misidentified as belonging to the old dialog instead of being a fresh call. Confirmed live against Asterisk via a PBX-side trace, this showed up two ways depending on timing:

  • 400 Bad Request (Warning: Retransmission with different CSeq) -- the new INVITE got matched against the old dialog's last-seen CSeq.
  • 486 Busy Here on a retry with the same Call-ID -- the callee looked busy because the stale dialog was still occupying it, when it wasn't actually busy.

Fix switches to uuid.uuid4(), which needs no persisted/cross-run state to guarantee uniqueness (uuid is already imported in SIP.py).

Fixes tayler6000#316

[FIX] Fixed gen_call_id deriving the Call-ID from a hash of an
      in-process counter, which restarts at the same value every time
      a new SIPClient is constructed. Short-lived processes (register,
      place one call, exit) generated an identical Call-ID on every
      run, which a server still holding a stale dialog under that
      Call-ID then treated as a malformed retransmission instead of a
      new call. Switched to uuid.uuid4(), which needs no cross-run
      state to stay unique.
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.

gen_call_id() produces the identical Call-ID across separate process runs (master/1.6.x)

1 participant