-
Notifications
You must be signed in to change notification settings - Fork 0
Add per-channel HLS server failover between primary and secondary endpoints #61
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
Conversation
Add seamless failover between LIVE_PRIMARY_HLS and LIVE_SECONDARY_HLS servers: - Track current active server and consecutive failure counts per server - Automatically switch to backup server after 3 consecutive failures - Record success/failure for all playlist and segment requests - Switch back to primary after 5-minute cooldown period when secondary is stable - Update all URL construction to use current active server - Add comprehensive logging for server switches and failures Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. 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:
|
paul-1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this seems overly complicated
If we get get multiple errors from the primary, switch to the secondary. Just stay on the secondary while the current stream is playing.
If playpack is stopped, and then resumed, then try the primary again.
If we get get multiple errors from the secondary, switch back to the primary. Just stay on the secondary while the current stream is playing.
Also, the current implementation assumes the playlist urls are the same, but they are not necessarily the same. The data from get_playlist_url looks like this
[
{
'size' => 'SMALL',
'name' => 'primary',
'url' => '%Live_Primary_HLS%/AAC_Data/9450/9450_variant_small_v3.m3u8'
},
{
'size' => 'MEDIUM',
'name' => 'primary',
'url' => '%Live_Primary_HLS%/AAC_Data/9450/9450_variant_medium_v3.m3u8'
},
{
'name' => 'primary',
'url' => '%Live_Primary_HLS%/AAC_Data/9450/9450_variant_large_v3.m3u8',
'size' => 'LARGE'
},
{
'size' => 'SMALL',
'url' => '%Live_Secondary_HLS%/AAC_Data/9450/9450_variant_small_v3.m3u8',
'name' => 'secondary'
},
{
'size' => 'MEDIUM',
'url' => '%Live_Secondary_HLS%/AAC_Data/9450/9450_variant_medium_v3.m3u8',
'name' => 'secondary'
},
{
'size' => 'LARGE',
'url' => '%Live_Secondary_HLS%/AAC_Data/9450/9450_variant_large_v3.m3u8',
'name' => 'secondary'
}
]
Based on feedback, simplified the failover implementation: - Removed cooldown period logic (no time-based recovery) - Changed to per-channel failover tracking (not global) - Reset to primary server when starting new playback session - Stay on current server for duration of stream Fixed playlist URL selection: - Parse playlist array for both primary and secondary entries - Select appropriate playlist based on channel's current server - Remove incorrect URL substitution logic - URLs come pre-formed from SiriusXM API Implementation now: - Tracks which server each channel is using (primary/secondary) - Switches to backup after 3 consecutive failures - Switches back to primary on opposite server failures - Automatically resets to primary when playback restarts Co-authored-by: paul-1 <6473457+paul-1@users.noreply.github.com>
Simplified the implementation as requested: Per-channel tracking: Each channel independently tracks its server (primary/secondary) and failure count Playlist selection fixed: Now correctly selects from separate primary/secondary playlist entries in the API response, not URL substitution Failover behavior:
Commit: 3af44b0 |
SiriusXM provides LIVE_PRIMARY_HLS and LIVE_SECONDARY_HLS endpoints for redundancy. Implemented automatic per-channel failover when the active server experiences persistent failures.
Changes
Per-channel server tracking
SERVER_FAILURE_THRESHOLD=3Failover logic
record_channel_failure(): Increments failure count per channel, triggers switch at thresholdrecord_channel_success(): Resets failure count for channelswitch_channel_server(): Handles per-channel server transitions and clears cached playlistreset_channel_server(): Resets channel to primary server when starting new playbackPlaylist selection
get_playlist_url(): Selects correct playlist entry from API response based on channel's current servernamefieldIntegration points
get_playlist_variant_url(): Track playlist request outcomes per channelget_segment(): Track segment request outcomes per channel, use channel's current serverBehavior
Switches to backup after 3 consecutive HTTP errors (403, 500, etc.). Stays on current server for duration of stream session. Automatically resets to primary when playback stops and resumes. If secondary fails, switches back to primary.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.