phpSmug and CURL Error 7
davenelson
Registered Users Posts: 4 Beginner grinner
Today for at least a couple hours I was receiving an error on my website using phpSmug and the PHP API. When the error was present and the code was on my home page it took a very long time for the code to throw an error and kept the rest of the home page from loading until it did.
It is working now, a test page is here http://davenelson.com/scripts/portfolio.php, but I am concerned about the effects of the error killing the performance of my web site and am not putting it back on my home page until I find a fix.
On the "discovery" tab under API Keys, I did not previously have the URL for my app, did that cause the error?
I plan on using this code on multiple pages, does each page need a unique API Key so that it can have a unique URL?
One thing I plan on doing is loading the entire thing using AJAX so it will not affect the performance of the home page and the other is putting some default images in the error block so that it will at least show something when the error occurs.
But I need to know, what causes this error and how do I fix it so that I never see it again?
P.S. About the app
I am using phpSmug to anonomously retrieve the URLs and Captions for the images in a gallery and insterting them into a JavaScript that uses Fotoramajs, a jQuery slideshow library, to display the images and captions in a responsive design that works great on all devices.
It is working now, a test page is here http://davenelson.com/scripts/portfolio.php, but I am concerned about the effects of the error killing the performance of my web site and am not putting it back on my home page until I find a fix.
On the "discovery" tab under API Keys, I did not previously have the URL for my app, did that cause the error?
I plan on using this code on multiple pages, does each page need a unique API Key so that it can have a unique URL?
One thing I plan on doing is loading the entire thing using AJAX so it will not affect the performance of the home page and the other is putting some default images in the error block so that it will at least show something when the error occurs.
But I need to know, what causes this error and how do I fix it so that I never see it again?
P.S. About the app
I am using phpSmug to anonomously retrieve the URLs and Captions for the images in a gallery and insterting them into a JavaScript that uses Fotoramajs, a jQuery slideshow library, to display the images and captions in a responsive design that works great on all devices.
0
Comments
As for stopping this from occurring again: you can't really do this as this is a network level issue. That said, you could probably have phpSmug timeout a little quicker so it has less of an impact. By default phpSmug uses a connect timeout of 5 seconds. This is probably a little high, but I went for the "safe rather than sorry" route.
You can reduce the timeout to 1 second for example using:
$f = new phpSmug( "APIKey=", "AppName=" );
$f->req->setConfig(array( 'timeout' => 1));
... and then continue with the rest of your code.
I have plans to make configuring the request settings a little easier for those who need to.
HTH
Colin
Personal Blog | Tech Blog | phpSmug
If I use disk based caching, can I get it to automatically pull from the cache when it times out and not clean out the cache even if it has expired if it is unable to connect to the API?
Personal Blog | Tech Blog | phpSmug
Colin, thank you for all your work on phpSmug.