Hi guys,
I am using the new Instafeed 2 RC 1 and having an issue where occassionally the API request times out and the feed won't load. Do you know why this is happening? Is it a connection speed issue?
Thanks
Hi @nomlas-design - it's a bit hard to say what the cause might be, but there are two options you can adjust to try to track it down or mitigate the problem: accessTokenTimeout and apiTimeout. Sounds like you're timing out on the API - does increasing apiTimeout (default is 5000ms) make the problem go away?
Hi @benjamin-hull - thanks for such a quick reply.
I tried to implement a preloader and changed the apiTimeout to 10 seconds but the api still seems to timeout every few times I do a hard reset. See here https://ecd.webflow.io/ for the code.
Thank you so much for helping
Hi @benjamin-hull @nomlas-design - same problem here. Receiving console error Error: api request error: 4 Application request limit reached periodically, no apparent pattern to it?
Hey folks — sounds like there are 2 separate issues going on here:
The timeout is controlled by Instafeed.js, and defaults to 5 seconds, but can be changed with the apiTimeout option. This means that if the API request to Instagram hasn’t returned within 5 seconds (or whatever the timeout is set to), Instafeed.js will cancel the request.
I chose 5 seconds as the default value for the timeouts, but it sounds like those might need to be increased, if people are getting “false positives”. (cc @benjamin-hull)
The request limit however, is not controlled by Instafeed.js. It’s a limit that’s enforced by the Instagram API, and controls how many requests can come from the same access token. There is feature request to add caching to help stay below this limit (see #656), but because requests are coming from the end-users’ browsers, there is always a chance the limit could be hit if there are a large number of page views in the same hour.
Hey @kaleidografik - check the comment on 656 - there's a relatively simple way to extend your request limit by adding extra test users to your app.
This does not work after all, sorry!
Hey @benjamin-hull - Even when updating the apiTimeout to 10000, IO'm still getting pretty regular timeouts. I would say it is working correctly 7/10 times, so the timeout is occuring pretty regularly for use in production.
I wonder if a callback (similar to before and after) could be implemented to allow us to take action if the API request times out? I wouldn't mind it if I could simply hide my Instafeed container on timeout error. Unless there is another way?
Hey @kaleidografik! Thanks for the suggestion!
In the current version, the error callback should get called when the API timeout is hit:
var feed = new Instafeed({
error: function(err) {
// handle error
}
});
Heads up though: the error callback actually gets called for any error that occurs, not just timeouts.
Hi @stevenschobert - great this is useful, thanks. I'm making my call via AJAX so was relying on that error callback at first, but this helps too. Just a heads up though, this doesn't fire if there is a problem with the call, such as an invalid secret.
Thanks for the help :)
@kaleidografik Which call are you making via AJAX? Is it to get your access token? If so, Instafeed.js supports doing that AJAX call inside the library, so it would get handled by the error option as well:
var feed = new Instafeed({
error: function(err) {
// will get called if access token call fails
},
accessToken: function(done) {
$.ajax({
url: instantTokenApiUrl,
dataType: 'json'
}).done(function(response) {
if (response.Token) {
done(null, response.Token);
} else {
done(new Error('error: ' + response));
}
});
}
});
This issue has been automatically marked as stale because it hasn't had new comments in the last 3 months. It will be closed if no further activity occurs. If you still need assistance with this issue, or believe it shouldn't be closed, please respond with a new comment to let us know.
Thank you all for your contributions.
Most helpful comment
Hey folks — sounds like there are 2 separate issues going on here:
The timeout is controlled by Instafeed.js, and defaults to 5 seconds, but can be changed with the
apiTimeoutoption. This means that if the API request to Instagram hasn’t returned within 5 seconds (or whatever the timeout is set to), Instafeed.js will cancel the request.I chose 5 seconds as the default value for the timeouts, but it sounds like those might need to be increased, if people are getting “false positives”. (cc @benjamin-hull)
The request limit however, is not controlled by Instafeed.js. It’s a limit that’s enforced by the Instagram API, and controls how many requests can come from the same access token. There is feature request to add caching to help stay below this limit (see #656), but because requests are coming from the end-users’ browsers, there is always a chance the limit could be hit if there are a large number of page views in the same hour.