Three race conditions in multi_worker_connection_manager could leave the Redis profile_connections:<id> counter permanently elevated with no active streams, causing all VOD requests to 503 "All profiles at capacity". Bug 1 — decrement_active_streams() return value was ignored All three generator exit paths (normal, GeneratorExit, Exception) called decrement_active_streams() and unconditionally set decremented = True regardless of whether the lock was acquired. On lock contention the decrement was silently skipped, active_streams remained > 0, the subsequent has_active_streams() check returned True, and _decrement_profile_connections() was never called. The counter was then stuck until manual DEL. Fix: add decrement_active_streams_and_check() which performs the decrement and the "are there remaining streams?" check atomically under a single lock, eliminating the race window. All three exit paths and the finally block now use this method and propagate its success/remaining return values. Bug 2 — non-atomic GET-then-DECR in _decrement_profile_connections() The previous implementation read the counter with GET then conditionally called DECR. Two concurrent decrements could both pass the > 0 guard and both fire, driving the counter to -1. A subsequent _check_and_reserve_profile_slot() INCR would then produce 0 which passes the <= max_streams check, allowing an extra stream to bypass the limit on the next request. Fix: replace GET-then-DECR with a direct DECR (matching the INCR-first pattern already used by _check_and_reserve_profile_slot) and clamp the result to 0 if it goes negative. Bug 3 — has_active_streams() read state without holding the lock The separate has_active_streams() call after decrement_active_streams() released its lock left a window where another concurrent stream could increment active_streams back to 1, causing the profile decrement to be skipped. This is resolved as a consequence of Bug 1's fix: the new decrement_active_streams_and_check() method reads active_streams while the lock is still held, eliminating the window entirely. Adds tests covering all three scenarios in apps/proxy/vod_proxy/tests/test_profile_connections.py. Fixes #1121. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .github | ||
| .idea | ||
| apps | ||
| core | ||
| dispatcharr | ||
| docker | ||
| docs/images | ||
| frontend | ||
| scripts | ||
| tests | ||
| .dockerignore | ||
| .gitattributes | ||
| .gitignore | ||
| .python-version | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| debian_install.sh | ||
| fixtures.json | ||
| LICENSE | ||
| manage.py | ||
| Plugins.md | ||
| pyproject.toml | ||
| README.md | ||
| version.py | ||
🎬 Dispatcharr — Your Ultimate IPTV & Stream Management Companion
📖 What is Dispatcharr?
Dispatcharr is an open-source powerhouse for managing IPTV streams, EPG data, and VOD content with elegance and control.
Born from necessity and built with passion, it started as a personal project by OkinawaBoss and evolved with contributions from legends like dekzter, SergeantPanda and Bucatini.
Think of Dispatcharr as the *arr family's IPTV cousin — simple, smart, and designed for streamers who want reliability and flexibility.
🎯 What Can I Do With Dispatcharr?
Dispatcharr empowers you with complete IPTV control. Here are some real-world scenarios:
💡 Consolidate Multiple IPTV Sources
Combine streams from multiple providers into a single interface. Manage, filter, and organize thousands of channels with ease.
📺 Integrate with Media Centers
Use HDHomeRun emulation to add virtual tuners to Plex, Emby, or Jellyfin. They'll discover Dispatcharr as a live TV source and can record programs directly to their own DVR libraries.
📡 Create a Personal TV Ecosystem
Merge live TV channels with custom EPG guides. Generate XMLTV schedules or use auto-matching to align channels with existing program data. Export as M3U, Xtream Codes API, or HDHomeRun device.
🔧 Transcode & Optimize Streams
Configure output profiles with FFmpeg transcoding to optimize streams for different clients — reduce bandwidth, standardize formats, or add audio normalization.
🔐 Centralize VPN Access
Run Dispatcharr through a VPN container (like Gluetun) so all streams route through a single VPN connection. Your clients access geo-blocked content without needing individual VPNs, reducing bandwidth overhead and simplifying network management.
🚀 Monitor & Manage in Real-Time
Track active streams, client connections, and bandwidth usage with live statistics. Monitor buffering events and stream quality. Automatic failover keeps viewers connected when streams fail—seamlessly switching to backup sources without interruption.
👥 Share Access Safely
Create multiple user accounts with granular permissions. Share streams via M3U playlists or Xtream Codes API while controlling which users access which channels, profiles, or features. Network-based access restrictions available for additional security.
🔌 Extend with Plugins
Build custom integrations using Dispatcharr's robust plugin system. Automate tasks, connect to external services, or add entirely new workflows.
✨ Why You'll Love Dispatcharr
✅ Stream Proxy & Relay — Intercept and proxy IPTV streams with real-time client management
✅ M3U & Xtream Codes — Import, filter, and organize playlists with multiple backend support
✅ EPG Matching & Generation — Auto-match EPG to channels or generate custom TV guides
✅ Video on Demand — Stream movies and TV series with rich metadata and IMDB/TMDB integration
✅ Multi-Format Output — Export as M3U, XMLTV EPG, Xtream Codes API, or HDHomeRun device
✅ Real-Time Monitoring — Live connection stats, bandwidth tracking, and automatic failover
✅ Stream Profiles — Configure different stream profiles for various clients and bandwidth requirements
✅ Flexible Streaming Backends — VLC, FFmpeg, Streamlink, or custom backends for transcoding and streaming
✅ Multi-User & Access Control — Granular permissions and network-based access restrictions
✅ Plugin System — Extend functionality with custom plugins for automation and integrations
✅ Fully Self-Hosted — Total control, no third-party dependencies
Screenshots
🛠️ Troubleshooting & Help
- General help? Visit Dispatcharr Docs
- Community support? Join our Discord
🚀 Get Started in Minutes
🐳 Quick Start with Docker (Recommended)
docker pull ghcr.io/dispatcharr/dispatcharr:latest
docker run -d \
-p 9191:9191 \
--name dispatcharr \
-v dispatcharr_data:/data \
ghcr.io/dispatcharr/dispatcharr:latest
Customize ports and volumes to fit your setup.
🐋 Docker Compose Options
| Use Case | File | Description |
|---|---|---|
| All-in-One Deployment | docker-compose.aio.yml | ⭐ Recommended! A simple, all-in-one solution — everything runs in a single container for quick setup. |
| Modular Deployment | docker-compose.yml | Separate containers for Dispatcharr, Celery, Redis, and Postgres — perfect if you want more granular control. |
| Development Environment | docker-compose.dev.yml | Developer-friendly setup with pre-configured ports and settings for contributing and testing. |
🛠️ Building from Source
⚠️ Warning: Not officially supported — but if you're here, you know what you're doing!
If you are running a Debian-based OS, use the debian_install.sh script. For other OS, contribute a script and we’ll add it!
🤝 Want to Contribute?
We welcome PRs, issues, ideas, and suggestions!
Here's how you can join the party:
- Follow our coding style and best practices.
- Be respectful, helpful, and open-minded.
- Respect the GNU AGPL v3.0 license.
Whether it's writing docs, squashing bugs, or building new features, your contribution matters! 🙋
📚 Documentation & Roadmap
- 📖 Documentation: Dispatcharr Docs
Upcoming Features (in no particular order):
- 🎬 VOD Management Enhancements — Granular metadata control and cleanup of unwanted VOD content
- 📁 Media Library — Import local files and serve them over XC API
- 👥 Enhanced User Management — Customizable XC API output per user account
- 🔄 Output Stream Profiles — Different clients with different stream profiles (bandwidth control, quality tiers)
- 🔌 Fallback Videos — Automatic fallback content when channels are unavailable
- 📡 Webhooks — Event-driven integrations and automations
❤️ Shoutouts
A huge thank you to all the incredible open-source projects and libraries that power Dispatcharr. We stand on the shoulders of giants!
⚖️ License
Dispatcharr is licensed under GNU AGPL v3.0:
For full license details, see LICENSE.
✉️ Connect With Us
Have a question? Want to suggest a feature? Just want to say hi?
➡️ Open an issue or reach out on Discord.
🚀 Happy Streaming! The Dispatcharr Team
Dispatcharr is a trademark of the Dispatcharr project.
Use of the Dispatcharr name or logo requires permission from the maintainers.