Keep alive: RFC 5626 outbound support and reconnect logic - #56
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 93.79% 93.93% +0.13%
==========================================
Files 24 24
Lines 1966 1994 +28
==========================================
+ Hits 1844 1873 +29
+ Misses 122 121 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
…, ob_param to ob_uri_param Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
codingjoe
left a comment
There was a problem hiding this comment.
@copilot we don't create new test classes for features. Unit tests must match their counterpart API. So one Class will have only one TestClass.
We also ONLY mock IO/transports, but otherwise avoid mocks to harden the implementation. We don't eat implementation but external behavior or and side effects of a function.
If you find other tests that don't need this criteria, clean up!
| self.disconnected_event.set() | ||
|
|
||
|
|
||
| async def start_server( |
There was a problem hiding this comment.
I didn't mean to create a new function, but use create_server.
There was a problem hiding this comment.
Removed start_server() in 06c4d7f. _serve_sip now calls asyncio.get_running_loop().create_server() directly, and the cookbook example uses loop.create_server() too.
…rpart classes Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Done in 06c4d7f. Collapsed |
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Done in 4cb7bff. Removed Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
Adds RFC 5626 outbound keep-alive support to the SIP UAC and introduces CLI-level automatic reconnection to keep long-running SIP sessions alive across network drops.
Changes:
- Add a periodic RFC 5626 double-CRLF keep-alive task,
Supported: outbound,;obContact parameter, and a publicdisconnected_eventto the SIP protocol. - Add reconnect loop with exponential back-off to the CLI
_connect_sip()implementation. - Update tests and documentation to reflect keep-alive / outbound / reconnect behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
voip/sip/protocol.py |
Adds keep-alive task, disconnected_event, ;ob Contact support, and Supported: outbound on REGISTER. |
voip/__main__.py |
Adds reconnect loop with back-off and logging for CLI SIP connections. |
tests/test_main.py |
Adds CLI tests covering retry on OSError and reconnect after disconnected_event. |
tests/sip/test_protocol.py |
Adds keep-alive task tests and updates REGISTER assertions for ;ob + Supported: outbound. |
docs/rfc_status.md |
Marks RFC 5626 support as “Complete” and documents implemented pieces. |
docs/feature_roadmap.md |
Updates roadmap text to mention outbound/reconnect and references start_server. |
docs/cookbook.md |
Updates example import to include start_server. |
You can also share your feedback on Copilot code review. Take the survey.
Implements full RFC 5626 client-initiated keep-alive and automatic reconnection with back-off.
RFC 5626 keep-alive (§4.4.1 + §5)
SessionInitiationProtocolnow spawns a_run_keepalive()task onconnection_madethat sends double-CRLF pings atkeepalive_interval_secs(default 30 s)REGISTERrequests advertiseSupported: outboundand add;obto the Contact URI per §5connection_lostcancels the keepalive task and sets the new publicdisconnected_event(asyncio.Event)Reconnect logic
_connect_sip()now loops with exponential back-off (1 s → … → 60 s), detecting drops viaprotocol.disconnected_event:Docs
docs/rfc_status.md: RFC 5626 status Partial → CompleteOriginal prompt
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.