dirkobrien56 Posted November 5, 2009 Share Posted November 5, 2009 So im having difficulties with skipping timeout error in curl my script calls different functions my problem is lets say if in function2 is curl timeout error it wont continue with function3 but kills entire script. Is there any way to skip function2 (if there is timeout error) and continue with function3 // Start calling functions function1(); function2(); function3(); function4(); function5(); Quote Link to comment https://forums.phpfreaks.com/topic/180414-curl-timeout-breaks-script/ Share on other sites More sharing options...
JonnoTheDev Posted November 5, 2009 Share Posted November 5, 2009 A HTTP request timeout should not kill your script. It is either the logic within your functions or your calling code that is doing this Quote Link to comment https://forums.phpfreaks.com/topic/180414-curl-timeout-breaks-script/#findComment-951844 Share on other sites More sharing options...
abazoskib Posted November 5, 2009 Share Posted November 5, 2009 you might have used curl_close() earlier than needed. hard to tell without any more code. Quote Link to comment https://forums.phpfreaks.com/topic/180414-curl-timeout-breaks-script/#findComment-951847 Share on other sites More sharing options...
dirkobrien56 Posted November 5, 2009 Author Share Posted November 5, 2009 you might have used curl_close() earlier than needed. hard to tell without any more code. Nope thats not problem simly website im calling is down and curl just cannot establish connection with it thats the case all i want to do is if website is down and curl times out the script should continue with another functions and skip this one which causes timeout. Quote Link to comment https://forums.phpfreaks.com/topic/180414-curl-timeout-breaks-script/#findComment-951865 Share on other sites More sharing options...
mrMarcus Posted November 5, 2009 Share Posted November 5, 2009 then your logic is wrong .. you're allowing the script to end if no connection is made. EDIT: really though, cURL timing out would only break your script if the code following the cURL is dependent on that call. otherwise, the script would continue to run, just without information from the cURL. Quote Link to comment https://forums.phpfreaks.com/topic/180414-curl-timeout-breaks-script/#findComment-951867 Share on other sites More sharing options...
JonnoTheDev Posted November 6, 2009 Share Posted November 6, 2009 then your logic is wrong .. you're allowing the script to end if no connection is made. EDIT: really though, cURL timing out would only break your script if the code following the cURL is dependent on that call. otherwise, the script would continue to run, just without information from the cURL. Exacly. When using CURL you should check for errors before trying to extract anything from the result. i.e. return an array <?php $return['file'] = curl_exec($ch); $return['status'] = curl_getinfo($ch); $return['error'] = curl_error($ch); curl_close($ch); if(!strlen($return['error'])) { // no error - continue } ?> Quote Link to comment https://forums.phpfreaks.com/topic/180414-curl-timeout-breaks-script/#findComment-952416 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.