CURL hangs by the server when curl_exec is called.

Testing in local environment (OSX Mavericks, apache server), server hangup function is done every time.

Incriminating line of code

$result = curl_exec($ch);

      

which is initialized like this:

   //initialize and setup the curl handler
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $this->_api_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, count($params));
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

    //execute the request
    $result = curl_exec($ch);

      

on execution (having all the variables parsed) the page just hangs indefinitely. removing the curl_exec command "fixes" the hang problem.

PHP 5.6.11

curl 7.38.0 (x86_64-apple-darwin12.5.0) libcurl / 7.38.0

OpenSSL / 0.9.8

Apache / 2.2.29 (Unix)

this answer ( fixing curl_exec freeze on windows 8 apache ) suggests multiple sessions are the problem ... I tried to end the session before calling curl_exec but it doesn't matter.

I have no idea to try! I have no debug information, because the server hangs and returns nothing. If anyone has any ideas what I could try, I would be very grateful! Thank you.

+3


source to share


1 answer


The problem was using the native OSX server capabilities. Switching to MAMP - a dedicated local web app for Mac - fixed the issue.



0


source







All Articles