hls.js not retrying when manifest request returns 404
What do you want to do with Hls.js?
I've also tried setting the manifestLoadPolicy -> errorRetry -> maxNumRetry = 10 No different. It tries once and completely gives up. In my case the server hasn't generated a manifest yet so it sends a 404 until it's ready. Why does hls.js not handle 404 errors?
What have you tried so far?
This is the expected behavior for 4xx errors.
You need to add a shouldRetry callback filter to return true for 404s if you want to keep requesting a URL that could not be found.
https://github.com/video-dev/hls.js/blob/master/docs/API.md#shouldretry
https://hlsjs.video-dev.org/api-docs/hls.js.retryconfig
@twilson90 you ever get this working? Looking for a similar solution. Didn't know if you had some code you could share. I'm using Vidstack.
This is what a custom shouldRetry callback for manifest request errors look like:
new Hls({
manifestLoadPolicy: {
default: {
maxTimeToFirstByteMs: Infinity,
maxLoadTimeMs: 20000,
timeoutRetry: {
maxNumRetry: 3,
retryDelayMs: 0,
maxRetryDelayMs: 0,
},
errorRetry: {
maxNumRetry: 2,
retryDelayMs: 1000,
maxRetryDelayMs: 8000,
shouldRetry: (
retryConfig,
retryCount,
isTimeout,
loaderResponse,
retry,
// Tailor the result to customize retry logic.
// HTTP status `loaderResponse.code` is ignored in this example:
) => retryCount < retryConfig.maxNumRetry
},
},
},