Note that there are some explanatory texts on larger screens.

plurals
  1. POcurl CURLOPT_TIMEOUT doesnt works, script executes forever
    primarykey
    data
    text
    <p>Here is my code</p> <pre><code> function exit_ajax($ex_return_value, $ex_ch=null, $ex_close_resource=false) { $output = array('return' =&gt; $ex_return_value); echo json_encode($output); if ($ex_close_resource) curl_close($ex_ch); exit(); } #ini_set("display_errors",1); #error_reporting(E_ALL); if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) exit_ajax("server value unset"); if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') exit_ajax("server value bad"); $nickname = $_POST['nickname']; $ch = curl_init(); if(!$ch) exit_ajax("CURL_INIT_NULL", $ch, true); curl_setopt($ch, CURLOPT_URL, "t.co"); curl_setopt($ch, CURLOPT_HTTPHEADER,array('User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4')); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $html = curl_exec($ch); if (!$html) exit_ajax("Errors: curl_getinfo: " . curl_getinfo($ch) . "; curl_error: " . curl_error($ch) . "; curl_errno: " . curl_errno($ch), $ch, true); $last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); curl_close($ch); exit_ajax("all fine"); </code></pre> <p>It executes with ajax call from some page. If desired site is up, all works fine. If its down (502/504), that script is running forever. What do i change to make it return t/o error?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload