mercredi 27 mars 2019

php CURL request being made after the Timeout

I currently have a laravel application which is doing a CURL request from one route to another route within the same route. My CURL looks like this

            //LOGGING THAT A CURL CALL IS ABOUT TO BE MADE 
            $url = env('APP_URL') . '/tests/add/results'; 
            $ch=curl_init();
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //return server error
            curl_setopt($ch, CURLOPT_HEADER, FALSE);
            curl_setopt($ch, CURLINFO_HEADER_OUT, FALSE);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, TRUE);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $test_post_data);
            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
            $response = curl_exec($ch);

In the route that the post is being sent to the first thing i log is the request data

        //LOGING THAT I RECEIVED THE CURL CALL in receiving function

Im noticing that the logs for the request data get logged exactly the same amount of time as the timeout meaning the request is actually being sent 10 seconds after the initial call

In my logs ill see something like

 10:10:10 - LOGGING CURL CALL
 10:10:20 - Recieving CURL call

if i change the timeout to 30 the the log shows 30 seconds later that i received the CURL call

Anyone have any idea why this may be happening.

The response from the CURL just comes back as false always



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire