0
我有兩臺服務器,一個給了API與終點,其他通過捲曲連接到第一個捲曲返回false只是有時
一切工作正常,但有時嫋嫋返回false ..如果我再試一次..它的工作原理再次。
你可以說,如果我停止發送請求捲曲2-3分鐘,然後再返回..第一次請求超時之後將返回false結束了..然後第二次嘗試都會好起來的..
這是很奇怪,,,你可以請建議我!
我的代碼:
$params = array(
"type" => 'Get',
"get_param" => 'Installments',
"language" => 'tr',
"client_ip" => $_SERVER['REMOTE_ADDR']
);
$api_url = 'https://blabla/portal/web/api/v1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$response = curl_exec($ch);
echo '<pre>';
var_dump($response);
var_dump(curl_getinfo($ch));
var_dump(curl_errno($ch));
var_dump(curl_error($ch));
echo '</pre>';
響應
bool(false)
array(26) {
["url"]=>
string(52) "https://blabla/portal/web/api/v1"
["content_type"]=>
NULL
["http_code"]=>
int(0)
["header_size"]=>
int(0)
["request_size"]=>
int(0)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(60.001051)
["namelookup_time"]=>
float(0.004364)
["connect_time"]=>
float(0.006517)
["pretransfer_time"]=>
float(0)
["size_upload"]=>
float(0)
["size_download"]=>
float(0)
["speed_download"]=>
float(0)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(-1)
["upload_content_length"]=>
float(-1)
["starttransfer_time"]=>
float(0)
["redirect_time"]=>
float(0)
["redirect_url"]=>
string(0) ""
["primary_ip"]=>
string(12) "82.222.47.39"
["certinfo"]=>
array(0) {
}
["primary_port"]=>
int(443)
["local_ip"]=>
string(13) "37.230.110.12"
["local_port"]=>
int(54335)
}
int(28)
string(71) "Operation timed out after 0 milliseconds with 0 out of 0 bytes received"
增加在這裏的時間,並檢查: - 'curl_setopt($ ch,CURLOPT_TIMEOUT,30);' –
它是60秒..相同的結果 –