A
A
Alexander Pantyukhov2016-05-19 11:10:59
Yii
Alexander Pantyukhov, 2016-05-19 11:10:59

Why does BaseCURL work locally but freeze on the server?

Hello. There are two functions that are responsible for checking if the proxy is alive:

public function run(){
        $db = db\Proxies::find()->all();
        foreach ($db as $item) {
            $md=self::curl($item->ip,$item->port,'http://yoip.ru/'); 
            if ($md['http_code']>=200&&$md['http_code']<=399){
                $db= db\Proxies::find()->where(['id'=>$item->id])->one();
                if(isset($db->id)){
                    $db->statusLive=1;
                    $db->save();
                    print_r($db->id."through http://yoip.ru/\r\n");
                }
            } else {
                $md=self::curl($item->ip,$item->port,'https://2ip.ru/');
                if ($md['http_code']>=200&&$md['http_code']<=399){
                    $db= db\Proxies::find()->where(['id'=>$item->id])->one();
                    if(isset($db->id)){
                        $db->statusLive=1;
                        $db->save();
                        print_r($db->id."through https://2ip.ru/\r\n");
                    }
                }else {
                    $db = db\Proxies::find()->where(['id' => $item->id])->one();
                    if (isset($db->id)) {
                        $db->statusLive = 0;
                    $db->save();
                        print_r("not passed \r\n");
                    }
                }
            }
        }
    }
    private function curl($ip,$port,$url){
        BaseCURL::$proxy['ip']=$ip;
        BaseCURL::$proxy['port']=$port;
        return BaseCURL::makeRequest([CURLOPT_URL => $url]);
    }

Locally, everything works fine, but when you upload it to the server, it freezes at the moment
return BaseCURL::makeRequest([CURLOPT_URL => $url]);

What could be the reason if pings pass from the server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pantyukhov, 2016-05-19
@Paromon

Found a solution

return BaseCURL::makeRequest([CURLOPT_URL => $url,CURLOPT_POST=>false,CURLOPT_COOKIE=>false,CURLOPT_COOKIEFILE=>false]);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question