简体   繁体   中英

Php script halts when called via async curl

This is a PHP code that calls $url:

        $handle = curl_multi_init();
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 6000);
        curl_setopt($ch, CURLOPT_USERPWD, "xxxx:xxxx");
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch,CURLOPT_COOKIE, CookieName . "=" .Security::getSid());
        //$output = curl_exec($ch);
        //curl_close($ch);
        curl_multi_add_handle($handle, $ch);
        $mrc = curl_multi_exec($handle, $active);

The problem: When called via curl, the script at $url halts without any error on a line with : print "something"; . If I take the url and open it in the browser then it works fine.

This started to happen this morning on an ubuntu 14.04 system without modifying any PHP scripts.

Note that both the caller and the $url are on htaccess (same machine, same htaccess credentials)

解决方案是在ajax-called php上调用session_write_close(),以便会话释放,从而防止锁定。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM