Sometimes but not always Curl requests for pages end up giving timing out, although the content does appear to be rendered correctly. There are 2 situations, firstly some plugins in Wordpress (WYSIJA in particular) and secondly a tracking script that records clicks from promotional emails that we send out, the script retrieving the page content using Curl before displaying it to the person who clicked on it. Looking at some of the server logs I wondered if this timing out (which causes page loads to be horrendously slow - up to and in excess of 10 seconds) was because we have no SSL defined on the server (IBM iSeries running ZendServer6) and Curl requests sometimes assume https not http. Any thoughts or experience on this?
Hi there, Bear with me.. im fairly new with php programming I have been experimenting with this myself recently.. i am developing a web app and the app runs 2 checks back to my license server (one is to check the username on the registered license) and the other is to check the validity of the license... What would happen with mine is that if my server took to long to respond it would cause the page to be slow.. (similar to you) and eventually not render the code correctly.. I found out that you can setup the parameters on your curl php call: CURLOPT_CONNECTTIMEOUT - The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. CURLOPT_TIMEOUT - The maximum number of seconds to allow cURL functions to execute. For example: curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); curl_setopt($ch, CURLOPT_TIMEOUT,400);//timeout in seconds Source: http://stackoverflow.com/questions/2582057/setting-curls-timeout-in-php In your case i would setup a "backup" option to when this time-out occurs.. replace with something (exactly what i did with mine)..and try to trace back why the timeout is happening.. In terms of tracking this back to why its happening? how have you got this setup? Hope this helps in some way.. Matt
Thanks. That sounds like it could help. Since the scripts are not ours (although we could edit them if necessary) I will check if we can set defaults for Curl timeouts and handling that would be best. Edited to add...... Well it doesn't look like you can set global defaults for Curl, but having set a timeout of 2 seconds and a connect timeout of 1 second (previously a timeout of 10 seconds and no connect timeout) it seems like the script executes faster. It's still slow but much faster than it was. I might experiment with shorter timeouts, since the script works, it just seems to be Curl not ending until the timeout is reached (or so it sems).