1 hour ago
Hi,
I'm having an IPTV problem which I think I have narrowed down to how NextPVR handles the User-Agent header for XC/M3U requests and live M3U8 streams.
This IPTV account still works correctly in TiviMate using Xtream Codes, but recently stopped working properly in NextPVR.
The original symptom in the NextPVR web player was:
Streaming Failed (transcoder exited)
After troubleshooting it, I think I have found a reproducible User-Agent issue.
SETUP
- NextPVR on Windows 10
- IPTV provider configured in NextPVR
- Same account/server works in TiviMate using "Xtream Codes parameters"
- Provider credentials are active and valid
- Account allows 2 connections
- Server/username/password omitted from this post
1. EXISTING NEXTPVR CHANNELS STOPPED WORKING
When trying to play a channel in the web player, NextPVR could not start the IPTV stream.
The eventual FFmpeg 404 was from NextPVR's own local /live URL, for example:
http://127.0.0.1:8866/live?channeloid=...
The important part of nrecord.log was earlier in the chain:
IPTV StartStream
Checking m3u8 stream (...)
Unable to StartStream(): One or more errors occurred. (A task was canceled.)
StartStream(...) allocated handle: 0
Handle: 0
Failed to start stream. Handle 0.
So the FFmpeg/transcoder error appears to be a consequence of the IPTV source failing to start, rather than an encoding problem.
2. "UPDATE CHANNELS" ALSO FAILED
Trying to update the existing IPTV source gave an empty "0 of 0 selected" channel list.
nrecord.log showed NextPVR attempting the provider M3U URL and receiving:
Downloading m3u https://<server>/get.php?....
Failed to download channel list:
System.Net.Http.HttpRequestException:
Response status code does not indicate success: 404 (Not Found).
at NShared.Recorders.IPTVScanner.WorkerThread()
However, the service is still active and working in TiviMate.
3. XC IMPORT ALSO RETURNS ZERO CHANNELS
I then tried adding a new IPTV device using "Import Using XC", entering the same server, username and password used by TiviMate.
NextPVR briefly showed "Logging in", then returned 0 channels.
The log showed the XC login failing with HTTP 404 in WebClient.DownloadString(), inside IPTVScanner.XCWorkerThread().
The same Xtream API endpoints work successfully in Chrome:
player_api.php?username=USERNAME&password=PASSWORD
player_api.php?username=USERNAME&password=PASSWORD&action=get_live_categories
player_api.php?username=USERNAME&password=PASSWORD&action=get_live_streams
All return valid data.
4. I CAN REPRODUCE THE XC 404 USING SYSTEM.NET.WEBCLIENT
This was the key test.
In Windows PowerShell I used the same System.Net.WebClient class:
$pw = Read-Host "Enter IPTV password"
$url = "https://<server>/player_api.php?username=USERNAME&password=$([uri]::EscapeDataString($pw))"
$wc = New-Object System.Net.WebClient
$wc.DownloadString($url)
Result:
Exception calling "DownloadString" with "1" argument(s):
"The remote server returned an error: (404) Not Found."
I then repeated the exact same request but added a User-Agent:
$wc = New-Object System.Net.WebClient
$wc.Headers["User-Agent"] = "Mozilla/5.0"
$wc.DownloadString($url)
This immediately succeeds and returns valid Xtream JSON containing user_info and server_info.
So:
System.Net.WebClient without User-Agent = HTTP 404
Same request with User-Agent: Mozilla/5.0 = success
This seems to match what happens in NextPVR's XCWorkerThread().
5. SAME THING HAPPENS WITH THE M3U DOWNLOAD
I downloaded the current provider M3U myself using:
$wc = New-Object System.Net.WebClient
$wc.Headers["User-Agent"] = "Mozilla/5.0"
$wc.DownloadFile($url, "C:\Users\Public\NPVR-data\current.m3u")
This succeeds.
The file is valid, starts with #EXTM3U, and contains the current channel URLs.
I imported this local M3U into a new NextPVR IPTV device successfully.
So the playlist itself is fine once it has been downloaded with a User-Agent.
6. THE ACTUAL LIVE STREAM ALSO REQUIRES A USER-AGENT
I then extracted one current M3U8 stream URL from the new playlist and tested that independently with System.Net.WebClient.
Without a User-Agent:
NO USER-AGENT: FAILED
The remote server returned an error: (404) Not Found.
With:
$wc.Headers["User-Agent"] = "Mozilla/5.0"
the exact same stream URL succeeds.
So the User-Agent requirement is not limited to the XC API or get.php download. It also applies to the actual live M3U8 stream.
7. LOCAL M3U WITH #EXTVLCOPT USER-AGENT
I created a one-channel M3U to test this in isolation:
#EXTM3U
#EXTINF:-1 tvg-name="LBW: HBO UA TEST",LBW: HBO UA TEST
#EXTVLCOPT:http-user-agent=Mozilla/5.0
http://<stream-server>/live/USERNAME/PASSWORD/STREAMID.m3u8
NextPVR imported this successfully.
When I tried to play it, NextPVR got as far as attempting the IPTV stream:
StartStream(...:LBW: HBO UA TEST)
IPTV StartStream
IPTV StartStream@2
IPTV StartStream@3
IPTV StartStream@3.1
IPTV StartStream@3.2
IPTV StartStream@3.3
IPTV StartStream@3.4
M3U8 (...)
Checking m3u8 stream (...)
It remained at "Starting Device. Please Wait..." for several seconds and then:
Unable to StartStream(): One or more errors occurred. (A task was canceled.)
StartStream(...:LBW: HBO UA TEST, ...) allocated handle: 0
Handle: 0
Failed to start stream. Handle 0.
The web player then showed "Streaming Failed (transcoder exited)".
8. TEST WITH |user-agent=Mozilla/5.0
I then created another one-channel test using the pipe/header syntax:
http://<stream-server>/live/USERNAME/PASSWORD/STREAMID.m3u8|user-agent=Mozilla/5.0
This produced a completely different failure.
The web player showed:
Error starting transcode: error: Internal Server Error
The new nrecord.log shows that this time NextPVR does not even get as far as IPTV StartStream.
Immediately after channel.transcode.initiate for the test channel:
InitiateTranscode
InitiateTranscode@2..
CaptureSource.LoadAll()
System.NullReferenceException: Object reference not set to an instance of an object.
at NShared.Extend.RequestHandlers.TranscoderHLS.InitiateTranscode(String& reason)
at NShared.Extend.ChannelRequestHandler.InitiateTranscode(Dictionary`2 parameters)
at NShared.Extend.ChannelRequestHandler.HandleRequest(String method, Dictionary`2 parameters)
at NShared.Extend.PluginFactory.HandleRequest(ServiceResponseStream serviceResponseStream, Dictionary`2 parameters)
at NPVR.Controllers.ServicesController.HandleServiceRequest(String body, String contentType)
So the |user-agent syntax appears to trigger a NullReferenceException inside TranscoderHLS.InitiateTranscode() in my setup.
SUMMARY
As far as I can tell:
1. The IPTV provider now requires an acceptable User-Agent.
2. Requests without one appear to deliberately receive HTTP 404.
3. I can reproduce this independently using System.Net.WebClient:
- no User-Agent = 404
- Mozilla/5.0 = success
4. This applies to:
- player_api.php / XC login
- get.php / M3U download
- the actual live M3U8 stream
5. This explains why TiviMate and Chrome work while NextPVR's XC/M3U requests fail.
6. Downloading the M3U manually with a User-Agent allows NextPVR to import the current channel list.
7. Adding #EXTVLCOPT:http-user-agent=Mozilla/5.0 does not allow the live stream to start.
8. Using:
|user-agent=Mozilla/5.0
causes a NullReferenceException inside:
NShared.Extend.RequestHandlers.TranscoderHLS.InitiateTranscode()
Would it be possible for NextPVR to send a normal User-Agent for:
- XC API requests
- M3U downloads
- M3U8 stream requests
or alternatively provide a configurable User-Agent for these requests?
Also, is the NullReferenceException when using the |user-agent syntax something that can be fixed?
I'm happy to provide the full nrecord.log (attached) and any other logs required, or test a patched build/DLL if useful.
Thanks.
I'm having an IPTV problem which I think I have narrowed down to how NextPVR handles the User-Agent header for XC/M3U requests and live M3U8 streams.
This IPTV account still works correctly in TiviMate using Xtream Codes, but recently stopped working properly in NextPVR.
The original symptom in the NextPVR web player was:
Streaming Failed (transcoder exited)
After troubleshooting it, I think I have found a reproducible User-Agent issue.
SETUP
- NextPVR on Windows 10
- IPTV provider configured in NextPVR
- Same account/server works in TiviMate using "Xtream Codes parameters"
- Provider credentials are active and valid
- Account allows 2 connections
- Server/username/password omitted from this post
1. EXISTING NEXTPVR CHANNELS STOPPED WORKING
When trying to play a channel in the web player, NextPVR could not start the IPTV stream.
The eventual FFmpeg 404 was from NextPVR's own local /live URL, for example:
http://127.0.0.1:8866/live?channeloid=...
The important part of nrecord.log was earlier in the chain:
IPTV StartStream
Checking m3u8 stream (...)
Unable to StartStream(): One or more errors occurred. (A task was canceled.)
StartStream(...) allocated handle: 0
Handle: 0
Failed to start stream. Handle 0.
So the FFmpeg/transcoder error appears to be a consequence of the IPTV source failing to start, rather than an encoding problem.
2. "UPDATE CHANNELS" ALSO FAILED
Trying to update the existing IPTV source gave an empty "0 of 0 selected" channel list.
nrecord.log showed NextPVR attempting the provider M3U URL and receiving:
Downloading m3u https://<server>/get.php?....
Failed to download channel list:
System.Net.Http.HttpRequestException:
Response status code does not indicate success: 404 (Not Found).
at NShared.Recorders.IPTVScanner.WorkerThread()
However, the service is still active and working in TiviMate.
3. XC IMPORT ALSO RETURNS ZERO CHANNELS
I then tried adding a new IPTV device using "Import Using XC", entering the same server, username and password used by TiviMate.
NextPVR briefly showed "Logging in", then returned 0 channels.
The log showed the XC login failing with HTTP 404 in WebClient.DownloadString(), inside IPTVScanner.XCWorkerThread().
The same Xtream API endpoints work successfully in Chrome:
player_api.php?username=USERNAME&password=PASSWORD
player_api.php?username=USERNAME&password=PASSWORD&action=get_live_categories
player_api.php?username=USERNAME&password=PASSWORD&action=get_live_streams
All return valid data.
4. I CAN REPRODUCE THE XC 404 USING SYSTEM.NET.WEBCLIENT
This was the key test.
In Windows PowerShell I used the same System.Net.WebClient class:
$pw = Read-Host "Enter IPTV password"
$url = "https://<server>/player_api.php?username=USERNAME&password=$([uri]::EscapeDataString($pw))"
$wc = New-Object System.Net.WebClient
$wc.DownloadString($url)
Result:
Exception calling "DownloadString" with "1" argument(s):
"The remote server returned an error: (404) Not Found."
I then repeated the exact same request but added a User-Agent:
$wc = New-Object System.Net.WebClient
$wc.Headers["User-Agent"] = "Mozilla/5.0"
$wc.DownloadString($url)
This immediately succeeds and returns valid Xtream JSON containing user_info and server_info.
So:
System.Net.WebClient without User-Agent = HTTP 404
Same request with User-Agent: Mozilla/5.0 = success
This seems to match what happens in NextPVR's XCWorkerThread().
5. SAME THING HAPPENS WITH THE M3U DOWNLOAD
I downloaded the current provider M3U myself using:
$wc = New-Object System.Net.WebClient
$wc.Headers["User-Agent"] = "Mozilla/5.0"
$wc.DownloadFile($url, "C:\Users\Public\NPVR-data\current.m3u")
This succeeds.
The file is valid, starts with #EXTM3U, and contains the current channel URLs.
I imported this local M3U into a new NextPVR IPTV device successfully.
So the playlist itself is fine once it has been downloaded with a User-Agent.
6. THE ACTUAL LIVE STREAM ALSO REQUIRES A USER-AGENT
I then extracted one current M3U8 stream URL from the new playlist and tested that independently with System.Net.WebClient.
Without a User-Agent:
NO USER-AGENT: FAILED
The remote server returned an error: (404) Not Found.
With:
$wc.Headers["User-Agent"] = "Mozilla/5.0"
the exact same stream URL succeeds.
So the User-Agent requirement is not limited to the XC API or get.php download. It also applies to the actual live M3U8 stream.
7. LOCAL M3U WITH #EXTVLCOPT USER-AGENT
I created a one-channel M3U to test this in isolation:
#EXTM3U
#EXTINF:-1 tvg-name="LBW: HBO UA TEST",LBW: HBO UA TEST
#EXTVLCOPT:http-user-agent=Mozilla/5.0
http://<stream-server>/live/USERNAME/PASSWORD/STREAMID.m3u8
NextPVR imported this successfully.
When I tried to play it, NextPVR got as far as attempting the IPTV stream:
StartStream(...:LBW: HBO UA TEST)
IPTV StartStream
IPTV StartStream@2
IPTV StartStream@3
IPTV StartStream@3.1
IPTV StartStream@3.2
IPTV StartStream@3.3
IPTV StartStream@3.4
M3U8 (...)
Checking m3u8 stream (...)
It remained at "Starting Device. Please Wait..." for several seconds and then:
Unable to StartStream(): One or more errors occurred. (A task was canceled.)
StartStream(...:LBW: HBO UA TEST, ...) allocated handle: 0
Handle: 0
Failed to start stream. Handle 0.
The web player then showed "Streaming Failed (transcoder exited)".
8. TEST WITH |user-agent=Mozilla/5.0
I then created another one-channel test using the pipe/header syntax:
http://<stream-server>/live/USERNAME/PASSWORD/STREAMID.m3u8|user-agent=Mozilla/5.0
This produced a completely different failure.
The web player showed:
Error starting transcode: error: Internal Server Error
The new nrecord.log shows that this time NextPVR does not even get as far as IPTV StartStream.
Immediately after channel.transcode.initiate for the test channel:
InitiateTranscode
InitiateTranscode@2..
CaptureSource.LoadAll()
System.NullReferenceException: Object reference not set to an instance of an object.
at NShared.Extend.RequestHandlers.TranscoderHLS.InitiateTranscode(String& reason)
at NShared.Extend.ChannelRequestHandler.InitiateTranscode(Dictionary`2 parameters)
at NShared.Extend.ChannelRequestHandler.HandleRequest(String method, Dictionary`2 parameters)
at NShared.Extend.PluginFactory.HandleRequest(ServiceResponseStream serviceResponseStream, Dictionary`2 parameters)
at NPVR.Controllers.ServicesController.HandleServiceRequest(String body, String contentType)
So the |user-agent syntax appears to trigger a NullReferenceException inside TranscoderHLS.InitiateTranscode() in my setup.
SUMMARY
As far as I can tell:
1. The IPTV provider now requires an acceptable User-Agent.
2. Requests without one appear to deliberately receive HTTP 404.
3. I can reproduce this independently using System.Net.WebClient:
- no User-Agent = 404
- Mozilla/5.0 = success
4. This applies to:
- player_api.php / XC login
- get.php / M3U download
- the actual live M3U8 stream
5. This explains why TiviMate and Chrome work while NextPVR's XC/M3U requests fail.
6. Downloading the M3U manually with a User-Agent allows NextPVR to import the current channel list.
7. Adding #EXTVLCOPT:http-user-agent=Mozilla/5.0 does not allow the live stream to start.
8. Using:
|user-agent=Mozilla/5.0
causes a NullReferenceException inside:
NShared.Extend.RequestHandlers.TranscoderHLS.InitiateTranscode()
Would it be possible for NextPVR to send a normal User-Agent for:
- XC API requests
- M3U downloads
- M3U8 stream requests
or alternatively provide a configurable User-Agent for these requests?
Also, is the NullReferenceException when using the |user-agent syntax something that can be fixed?
I'm happy to provide the full nrecord.log (attached) and any other logs required, or test a patched build/DLL if useful.
Thanks.