Skip to content
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

Indicate HTTP Status Code on networkError Errors #5339

Closed
ddurham2 opened this issue Mar 25, 2023 · 4 comments
Closed

Indicate HTTP Status Code on networkError Errors #5339

ddurham2 opened this issue Mar 25, 2023 · 4 comments
Labels
Feature proposal Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix.

Comments

@ddurham2
Copy link

ddurham2 commented Mar 25, 2023

Is your feature request related to a problem? Please describe.

In implementing an HLS player, I've found that hls.js will continue to request segments/playlists for as long as the ___MaxRetry configuration values allows.

However, it's possible that the HTTP code can indicate if the stream is still valid or not. i.e. a 503 may indicate that the server is busy and that's recoverable so it should keep retrying (following backoff header if it doesn't already). But a 404 could be interpreted by the player as a indicator that the stream has ended (which is true in the case of my HLS server).

Describe the solution you'd like

I would suggest adding information about the HTTP response in the object given to the error event callback of type networkError.
Minimally, it should include the HTTP status code.

This would allow my player implementation, after a sustained network stall, to make a more informed decision, and could stop the process of needlessly retrying a stream that is gone much before the maxRetries are exhausted.

Additional context

Nevertheless, a great library!

@ddurham2 ddurham2 added Feature proposal Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix. labels Mar 25, 2023
@robwalch
Copy link
Collaborator

Hi @ddurham2,

The player does this already. The next release has a number of improvements in error handling that you can try now in dev. Have a look at #5241 to see how the new network error policies and error handling controller improve the handling of network errors.

@robwalch
Copy link
Collaborator

The ERROR events' ErrorData type has response.code where you'll find the http status code if the error originated from a bad response.

In dev there is a helper called shouldRetry that checks if it's worth retrying or not. There is no a way to customize it as of yet. Let me know how this works for you.

@ddurham2
Copy link
Author

Ah, very cool! I was just blindly following what's shown here: https://github.com/video-dev/hls.js/blob/master/docs/API.md#fifth-step-error-handling and didn't think to check if data had more info. It certainly does, and I see the status code now.

Thanks!

@robwalch
Copy link
Collaborator

Ah, very cool! I was just blindly following what's shown here: https://github.com/video-dev/hls.js/blob/master/docs/API.md#fifth-step-error-handling and didn't think to check if data had more info. It certainly does, and I see the status code now.

Good to know! That section of the docs could use some sprucing. The description of response.code should also clearly state that it contains http status error codes for network errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature proposal Needs Triage If there is a suspected stream issue, apply this label to triage if it is something we should fix.
Projects
None yet
Development

No branches or pull requests

2 participants