我设置了超时和set_time_limit的所有选项,但没有帮助。 40分钟后CURL得到500错误。在远程服务器上启动长时间进程,我需要等待完成。如果文件很小 - 一切正常,如果文件很大 - 40秒后出现500错误。这是我的代码:CURL在40秒后得到500错误
$curl = curl_init("http://example.com/index.php?page=uploads");
curl_setopt($curl, CURLOPT_POST, 1);
$datas = array(
"id" => $id,
"video" => $filename->new_file_name,
"title" => $_POST["title"],
"description" => $_POST["description"],
"category" => array($_POST["category"]),
"location" => $_POST["location"],
"check" => $check,
"start" => $start,
"duration" => $duration
);
$data = json_encode($datas);
$fp = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
curl_setopt($curl, CURLOPT_VERBOSE, 1);
curl_setopt($curl, CURLOPT_STDERR, $fp);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 900000);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOSIGNAL, 1);
curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($curl, curl_exec, 0);
curl_exec($curl);
print_r(curl_getinfo($curl));
curl_close($curl);
你应该在你的服务器端有错误检查,因为HTTP错误500的意思是“内部服务器错误”。 –
你使用正确的网址(http://example.com/index.php?page=uploads)吗? – mishanon
是的,这是正确的网址。远程服务器上的脚本启动。远程脚本通过curl获取命令,解析POST,开始转换文件...文件被转换并保存在文件夹中。日志没有错误。在远程服务器上成功完成脚本。但开始后40秒卷曲给我500错误。但是CURL必须获得关于完成的成功消息。它变成断开连接。它总是40秒... –