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

Retry after network error #1805

Closed
steelbrain opened this issue Jan 16, 2015 · 17 comments
Closed

Retry after network error #1805

steelbrain opened this issue Jan 16, 2015 · 17 comments
Labels
confirmed pinned Things that stalebot shouldn't close automatically

Comments

@steelbrain
Copy link

steelbrain commented Jan 16, 2015

Cloudflare has a bug or something that when a video is streaming for about ten minutes, It'll close the connection. You'll have to refresh the page to reload the video and fast forward to where you were.

It'd be nice to make videojs catch that error and retry to download the video atleast once.

@heff
Copy link
Member

heff commented Jan 16, 2015

That would be cool. For the most part we try to mimic how the video element works exactly in the core player, but I think that could be a really useful plugin. Any interest in putting one together?

@heff heff added the plugin label Jan 16, 2015
@steelbrain
Copy link
Author

steelbrain commented Jan 16, 2015

okay sure!

@heff
Copy link
Member

heff commented Jan 16, 2015

Nice! I'm gonna close this issue since it doesn't require changes to core, but we can continue to discuss this here if you have any questions or want feedback.

@heff heff closed this as completed Jan 16, 2015
@ksheurs
Copy link

ksheurs commented Jun 17, 2015

Happen to know if something like this ever came about? We started tracking errors/exceptions in production and there is surprisingly a lot of network issues: "The video could not be loaded, either because the server or network failed or because the format is not supported." or "A network error caused the video download to fail part-way.".

If not, what would be the best approach for a plugin? Listen for when VideoJS throws error code 2 and then reload the source? Thanks!

@mmcc
Copy link
Member

mmcc commented Jun 17, 2015

@ksheurs I know a few other folks did something along those lines, so I think that sounds reasonable.

@ahomu
Copy link

ahomu commented Aug 31, 2015

Already a plugin to solve this problem?

@andrey-sw
Copy link

I have a similar problem.

player.on('error', function(event) {
if (player.error().code === 2) {
player.error(null); // clear out the old error
//////////////////////////////////////////////////
// player.src(sources); // retry
// dont work
/////////////////////////////////////////////////////
// player.load();
// player.start();
// dont work
///////////////////////////////////////////////////////
return;
}
});

how to restart the video, it is desirable from the same position when the network is restored

@hryuk
Copy link

hryuk commented Mar 24, 2016

Any updates on this?

@richardrails
Copy link

any updates?

@billwing
Copy link

I try this and solve the problem.

var player = videojs('player', {}, function() {
    this.on('error', function(event) {
        var time = this.currentTime();

        if(this.error().code === 2) {
            this.error(null).pause().load().currentTime(time).play();
        }
    });
});

@JeffreyWay
Copy link

I experience this often. Almost identical to what @ksheurs said. Would love an official workaround or solution for this...

@gkatsev
Copy link
Member

gkatsev commented Feb 22, 2017

This seems like an often requested feature that when a source errors to try the next source in the list, if available. Given that videojs tries to make life easier, this seems like something that should be in core, so, I'm going to re-open this.

@gkatsev gkatsev reopened this Feb 22, 2017
@gkatsev gkatsev added confirmed and removed plugin labels Feb 22, 2017
@kavin-90
Copy link

@gkatsev thanks

@Yalhu
Copy link

Yalhu commented Apr 11, 2018

It's great if this feature added in video.js core. I resolve this issue according to @sylvio-ruiz(#4044) and @billwing .

var timer;
function onerror(){
  switch(player.error().code){
    case 2:
       document.getElementById('loadvideo').style.display = 'block';
       timer=player.setInterval(()=>{player.load().currentTime(time).play()},5000)
       break;
  }
}
function onplaying(){
  player.clearInterval(timer);timer=null;
}

I want to know which API should I use , setTimeout or setInterval. error.code==4 will handle every other time. error.code==2 only handle once.
And is onplaying the right event that I clear Interval?

There is an another issue: player error event doesn't fire on mobile #5089.

@gkatsev gkatsev added the pinned Things that stalebot shouldn't close automatically label Jul 2, 2018
@wowcut
Copy link

wowcut commented Jul 25, 2018

I am looking for exactly this and I am not able to answer these questions myself from the docs atm:

  • How is the current state of reloading videos on errors?
  • What is the current best practice?
  • Does videojs handle reloading the same source or loading next source on error at all?
  • If yes, how can I configure the number of reload tries and timeouts?
  • Does exist some advanced logic, e.g. increasing timeouts with each reload, like found in many network softwares that must handle network errors?
  • Do I have to use some of the code snippets that fly around this issue tracker?
  • If yes, I would really like to see a best practice code snippet right from the devs, tested and approved with your incredible test infrastructure.

Reloading on error is very important for a robust experience. It would be very appreciated if videojs devs would like to tackle this, make this a first class feature and add some canonical documentation about it, so it is clear how to handle that, which feature details exactly are supported and what the user has to do to.

Thank you very much for your attention!

@jayarjo
Copy link

jayarjo commented Jun 3, 2019

Bump.

@gkatsev
Copy link
Member

gkatsev commented Jan 19, 2021

It's been a while, but we're finally adding this in. For now, we're doing it just as an option, but we'll consider enabling it by default in the future. See #7038

tf pushed a commit to tf/video.js that referenced this issue Feb 18, 2022
Add a `retryOnError` option. When set, during source selection, if a source fails to load, we will retry the next item in the sources list. In the future, we may enable this by default.

A source that fails during playback will *not* trigger this behavior.

Fixes videojs#1805.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 25, 2022
edirub pushed a commit to edirub/video.js that referenced this issue Jun 8, 2023
Add a `retryOnError` option. When set, during source selection, if a source fails to load, we will retry the next item in the sources list. In the future, we may enable this by default.

A source that fails during playback will *not* trigger this behavior.

Fixes videojs#1805.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
confirmed pinned Things that stalebot shouldn't close automatically
Projects
None yet
Development

No branches or pull requests