codemonauts / craft-instagram-feed

Craft CMS plugin to receive Instragram feed data as variable in templates
MIT License
27 stars 7 forks source link

Request Timeout #40

Closed simonda86 closed 3 years ago

simonda86 commented 3 years ago

I had an issue on Black Friday, I'm assuming this was due to the amount of traffic on a very busy day. But the request to the proxy server was timing out, this was then throwing a timeout exception in Guzzle which was causing the homepage to return an error. For speed, I removed this section to fix the issue.

But I'm wondering if there is a way that I can catch the exception to then hide the section from my home page to prevent an error showing in future?

fleaz commented 3 years ago

In the config file where you configured the proxy, you can set a timeout value for Guzzle requests. The default value is 5 seconds.This is probably higher than the timeout which is configured on your webserver and therefore you will get an timeout error when guzzle is still waiting for the response but your server is stopping the request.

To fix this, you can configure a lower timeout in the config file. If guzzle reaches it's timeout, it will either return the old images it still had cached what keeps the page intact (and most user won't even notice that the latest image is not present ) or if there is no cached data (because it's a fresh installation or you cleared the cache) it will return an empty list which you can e.g. handle in the template with an if/else.

So in both cases, your page should still work even if guzzle canceled the request to our proxy :)

simonda86 commented 3 years ago

Thanks so much!

fleaz commented 3 years ago

Hey @simonda86,

we just released v1.0.6 which handles the guzzle exception and wont crash the whole page when the plugin encounters a timeout