POST requests for specific URL are taking 3 minutes

Asked

Viewed 274 times

0

All my POST type requests for a specific URL are taking about 3 minutes to return the sponse, that is, a few seconds after I submit the form, I look at the API website and there is my data posted, but on my site the request is pending, after exact 3 minutes it is finalized returning the required data.

I believe something is holding the answer for 3 minutes as I tested the same code in local environment and worked quickly (took about 10 seconds), which may be causing this "slowness"?

public function http_request($url, $headers, $data = array())
{
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, 'https://api.binance.com/api/v3/order');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    if ($data) {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    curl_setopt($ch, CURLOPT_ENCODING, "");
    $content = curl_exec($ch);

    curl_close($ch);
    return $content;
}

inserir a descrição da imagem aqui

  • 1

    It is possible to restart the server?

  • Yes it is possible, but the POST in other Apis is faster, less than 10 seconds.

  • Yes. I understood that it works fast on another machine, so I suggested resetting the server.

  • Not on another machine, on the same server, if I send a POST to another different API, it’s pretty fast. Even so I will restart it to "ensure".

  • I get it. Well, in that case the possibility of solving has greatly diminished. :(

  • Unfortunately not solved, how can it take 3 minutes to return a reply kk? I still do not believe it

  • 1

    Are you sure it’s the http_request it takes 3 minutes? There is nothing before or after? When you do the curl for the same site via terminal it takes the same 3 minutes? Curl, Openssl, GZIP and PHP are updated in the latest version?

  • Yes, they’re up to date. I can’t test from the terminal

  • I tested by the terminal @Inkeliz and it seems that worked very fast

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.