PHP Multicurl工作一段时间然后在Godaddy共享主机

时间:2017-01-26 22:45:42

标签: php curl shared

好吧,所以我有一个脚本,它使用滚动卷曲来处理多个请求。过去两天,它可以工作几次,但最终它开始提供500错误。我尝试了一个常规的curl_init,这样可行,所以我知道我正在连接我正在连接的网站。如果我等了明天它会再次运作。所以我想有一些泄漏或正在发生的事情。我无法弄清楚如何检查Godaddy上的500个错误。但有没有办法可以检查卷曲,看看问题是什么,或者从无限循环中阻止它。因为它没有连接。只是为了澄清完全相同的脚本起作用,但经过一定次数的尝试后,它就会停止。

while (($execrun = curl_multi_exec($this->multi_handle, $running)) == 
CURLM_CALL_MULTI_PERFORM) {
        ;
}

if ($execrun != CURLM_OK) {
        break;
}   

//not entering this loop
while ($info = curl_multi_info_read($this->multi_handle)) {

}

编辑:我一次做大约30个请求。它工作得非常快,并且像我加载脚本的前4-5次一样工作。但最终它会停止,我将不得不等待第二天。这是while循环,其中只关闭句柄的次数是。我以前从未遇到过这个问题。不知道在哪里看。它只是不会连接到网站并进入此循环。

        while ($info = curl_multi_info_read($this->multi_handle)) {

        $ch = $info['handle'];
        $ch_array_key = (int)$ch;


        if (!isset($this->outstanding_requests[$ch_array_key])) {
            die("Error - handle wasn't found in requests: '$ch' in ".
                print_r($this->outstanding_requests, true));
        }

        $request = $this->outstanding_requests[$ch_array_key];
        $url = $request['url'];

        $content = curl_multi_getcontent($ch); 
        $callback = $this->curl['CALLBACK'];  

        $user_data = $request['user_data'];

        if(curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200)
        {
            call_user_func($callback, $content, $url, $ch, $user_data, $user_data);
            unset($this->outstanding_requests[$ch_array_key]);

            curl_multi_remove_handle($this->multi_handle, $ch);
            curl_close($ch);
        }
        else
        {
            //unset the outstanding request so it doesn't get stuck in a loop
            unset($this->outstanding_requests[$ch_array_key]);
            curl_multi_remove_handle($this->multi_handle, $ch);
            curl_close($ch);                

            //these come back as 0's, so not found. Restart the request
            self::startRequest($url);   
        }
        //self::msg('USER END');
    }

0 个答案:

没有答案