PHP:为什么CURL工作不一致?

I am trying to execute this simple script in php:

$ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, 0); // no headers in the output
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // output to variable
        curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
        curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
        curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
        curl_setopt($ch, CURLOPT_PROXYUSERPWD, $opts['credentials']);
        $data = curl_exec($ch);
        curl_close($ch);

        echo $data;

I don't know if this is a problem with some tipe of TimeOut or it needs another paramter but sometimes brings the page and others not, why this happens?

Wath I did is checked errors with "curl_error", that led me to the problem. Thanks.