Fix bare KeyError crash in _callback_RESP_NotFound / _callback_RESP_Unavailable - #320
Open
hainesdev wants to merge 5 commits into
Open
Fix bare KeyError crash in _callback_RESP_NotFound / _callback_RESP_Unavailable#320hainesdev wants to merge 5 commits into
hainesdev wants to merge 5 commits into
Conversation
Fixes tayler6000#85 [FIX] Fixed _callback_RESP_NotFound and _callback_RESP_Unavailable checking `if call_id not in self.calls` and logging a debug message, but never returning afterward, unlike the otherwise identical _callback_RESP_OK. Both fell through into self.calls[call_id]... and crashed with a bare KeyError. Reachable in normal operation: invite()'s own blocking response loop can hand either of these an early response (e.g. a 404 on a registration, or a 503 on a pre-auth probe INVITE) that arrives before the call/registration is registered in self.calls.
When the remote swaps its media source mid-call (e.g. Asterisk dialplan playback -> a bridge) the new source picks a fresh random RTP timestamp base while the sequence number stays contiguous. RTPPacketManager.write then seek()s gigabytes into the buffer and playback never recovers. Mirror the existing large-backward-jump guard: on a forward delta past the same 100000-byte threshold, reset the buffer to the new packet as a fresh reference point. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
pyVoIP could receive RFC 2833 DTMF but never send it. Add RTPClient.send_dtmf() / VoIPCall.send_dtmf(): a queued burst of telephone-event RTP packets (marker on the first, three redundant end packets, frozen event timestamp) that pre-empts the audio stream in trans() one 20 ms packet per iteration so tone timing is preserved. No-op when the peer did not negotiate telephone-event. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The first attempt (b3d5dc2) compared each packet's timestamp to the buffer base self.offset, which only ever decreases -- so a normally advancing stream is eventually always >100000 past its own base and every packet rebuilt the buffer, starving playback ~12s in. Track self.last_offset (the previous write's timestamp) and only rebase when a packet jumps far past *that* -- a genuine media-source switch, not routine forward progress. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Register OPTIONS as a compatible method and reply to it (to the Via sender, falling back to the configured server) so proxies that probe the client with OPTIONS don't treat the registration as dead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #85
_callback_RESP_NotFoundand_callback_RESP_Unavailablecheckif call_id not in self.callsand log a debug message, but (unlike the otherwise-identical_callback_RESP_OK, which already has the correctreturn) never actually return afterward -- so they fall through intoself.calls[call_id]...and crash with a bareKeyErrorinstead of the graceful handling the surrounding code clearly intended.This matches the traceback in #85 exactly: a 404 arriving during registration lands in
_callback_RESP_NotFoundbefore the call/registration is inself.calls, and crashes withKeyError: '<call-id>'. It's also reachable from a normal call attempt:invite()'s own blocking response loop can hand either callback an early response (e.g. a 503 on a pre-auth probe INVITE) that arrives beforeVoIPPhone.call()has gotten around to registering the call inself.calls.Fix adds the missing
returnto both, matching the pattern_callback_RESP_OKalready uses correctly.