-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
How to make VideoJS retry after errors #3725
Comments
Would just like to +1 this. The only work around I have found is 1 Check for the 2 If either of the above occur then cause a complete page reload. All other attempts fail to reload the video including what I thought would definitely work: More than happy to provide more info/debug if required. |
Do you have any idea which library is failing? The video element will send stalled events if it doesn't get data, but it shouldn't crash. I'm guessing hls.js is the root that is getting into a nasty state. I am surprised that a dispose and re-initializaton doesn't solve the problem. Have you tried destroying the video element and creating a new one? |
Actually, I can now re-initialize the video by doing an AJAX load of the video element and then calling The tricky part is figuring out when the the video is no longer going to restart/resync. By trial and error we have settled on running a JS function every 10 seconds which causes a complete reload via AJAX if any of the following are true:
|
Hi @brodjustice , I'm struggling with the same issue. Would you mind to provide a sample of your code? |
Put my code here following @brodjustice 's recommendation, while I'm not sure how to customize the error message, or simply hide it when retrying, can anybody help?
|
@Hailong Sorry about my late response, the holiday period and everything... I cannot post my exact code here as it is all mixed up with other functions (yes, I know...). But next week I will try and re-factor it and post some proven working code. |
@brodjustice How is the code sample going? 😄 Thanks! |
what i know videojs try to connect few times if video has network error after few try it show that network error |
Sorry, I realize that I'm probably never going to get back to that project to rewrite the javascript. However, I can paste the nasty looking code here that actually works - hope it's all there as I had to cut and paste sections from all over the js file. If I ever get back to clean this up into a closure I'll post again but in the meantime this might give some hints - it needs jquery:
|
It was fixed in videojs-contrib-hls ( |
Yup, you basically want to listen to the error event and then set the source on the player again. |
Actually it reloads source only once :( Need to get an endless loop. |
Me too, I can't find any docs about reloadSourceOnError |
I've got the same issue here. Has anyone got a working example using |
@diegoje I am now using hls.js, this is the core lib for many players, including this, with hls.js I got it. |
@rof20004 I have the same problem right now. I can not get to the error messages ran. Can you explain your approach with hls.js? |
@badasscode
Retry method:
|
hideErrorMsg is not important, do not use if you do not understand, but I used this variable only to show few messages. |
Thx a lot 👍 |
Hls.js has serious memory leak. |
"wich is a mosaic with 20 live streams videos (for monitoring) and it increases the memory at the point of crashing the browser (my computer has 32G of ram memory)" Maybe you need to change you goals with hls.js, see 20 live streams in same time in only one cpu is not usual. |
@rof20004 |
@ssaguiar - here are the docs I found for reloadSourceOnError: https://support.brightcove.com/hls-plugin It won't solve your memory leak issue, though. I am working on something similar right now, which is a video monitoring site/tool, and memory management is a big issue when playing 12 - 36 streams simultaneously. From what I can tell, the virtual media source extension code in the newest hls plugin (https://github.com/videojs/http-streaming) doesn't "properly" handle all scenarios that can occur when using MSE, which contributes to the memory leak issues. I don't currently have a good workaround for this. We ended up not using HLS in the end because of the latency. |
Description
We're seeing some issues where videojs with contrib-hls may lose connectivity to a live video source due to circumstances beyond its control such as network outage and similar. In this case videoJS stops playing and throws an error.
I need to sort out a way to capture this error and handle in my code. I would like to display a message that there is an issue and "reconnection is in progress" and then implement an exponential back off type re-try to reconnect the video source.
Basically I want to allow it to try as hard as it can to keep a stream up or re-establish a stream after interruption.
I've tried capturing errors thrown by the video tag by attaching to 'error' and capturing in my function. This works but I cannot determine how to re-start video JS on such a circumstance. I have tried using reset(), pause()/play(), load() etc in various patterns to attempt to re-initialize the player.
Is there a way to handle this currently? Or perhaps some inbuilt functionality that says "don't throw an error, just keep trying...."
Steps to reproduce
Connect to any HLS live stream and then interrupt your network.
Results
Expected
Would like to see a method or procedure to re-initialize the player to ask it to re-attempt playing the video.
Alternatively a functionality in the player that makes it aggressive about reconnections / automatically re-trying after an network (or media) error.
Actual
Player stops with network (or media) error indication.
Error output
If there are any errors at all, please include them here.
Additional Information
Please include any additional information necessary here. Including the following:
versions
videojs
Version 5.11.6
videojs-contrib-hls 3.5.3
browsers
All, eg firefox
OSes
what platforms (operating systems and devices) are affected?
plugins
videojs-contrib-hls 3.5.3
The text was updated successfully, but these errors were encountered: