Skip to content

[Bug]: No user-agent being sent in stream probes or previews from ECM #995

Description

@hudsgiant

ECM Version

0.18.2-0027

Priority

Priority 4: When you get to it

What is the bug?

Issue appears to be a lack of user-agent header being passed by ECM. Gemini suggests:

Root Cause Analysis

  1. What Dispatcharr Does
    When you preview or play a channel in Dispatcharr:
  • Playback routes through Dispatcharr's proxy (/proxy/ts/stream/<channel_uuid>).
  • In apps/proxy/live_proxy/input/manager.py and http_streamer.py, Dispatcharr fetches the stream with an explicit User-Agent header:
  • It checks the stream's M3U Account or StreamProfile (on your setup, these are configured to use TiviMate: TiviMate/5.1.6 (Android 12)).
  • If none is set, it falls back to Dispatcharr's default (VLC/3.0.20 LibVLC/3.0.20).
    IPTV providers recognize the legitimate media client header and serve the stream (typically returning a 302 Found redirect followed by 200 OK).
  1. What EnhancedChannelManager Does
    When you preview a stream in EnhancedChannelManager (Streams pane):

The frontend requests GET /api/stream-preview/{stream_id} from stream_preview.py.
ECM obtains the raw provider URL from Dispatcharr and attempts to connect directly to the IPTV provider using stream_request() or validated_subprocess_input().

No headers or User-Agent parameter is passed in stream_preview.py:
python
# backend/routers/stream_preview.py (lines 106-113)
async def passthrough_generator():
    async with stream_request(
        stream_url, timeout=None, initial_target=initial_target
    ) as response:
        response.raise_for_status()
        async for chunk in response.aiter_bytes(chunk_size=65536):
            yield chunk

Because no headers are specified, the underlying Python httpx client sends:
http User-Agent: python-httpx/0.27.x

Most commercial IPTV providers immediately drop connections or return HTTP 403 / 406 / Connection reset when they detect python-httpx.
mpegts.js in the browser receives the HTTP error and aborts playback.

(Note: Interestingly, in ECM's stream_prober.py, the author noticed this issue for bitrate probing and added headers = {"User-Agent": "VLC/3.0.20 LibVLC/3.0.20"}, but omitted it in stream_preview.py.)

Steps to Reproduce

Seems to affect some providers and not others, but basically either just preview a stream for an affected provider in ECM. It will fail, but work fine from within Dispatcharr - both on the same network.

Screenshots / Logs / Artifacts

No response

Additional Context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions