POST requests for script are taking 3 minutes
All my POST-type requests for a specific URL are taking about 3 minutes to return the response, that is, a few seconds after I submit the form, I look at the API site and there are my data posted, but on my site the request is pending, after exactly 3 minutes it is finished returning the necessary data.
I think something is holding the response for 3 minutes because I tested the same code in the local environment and it worked quickly (it took about 10 seconds), what could be causing this "slowness"?
i.stack.imgur.com/XFRmp.png
-
Really don't have enough information here. This is going to depend on what the script you are posting to is doing before it returns something. This would have to be diagnosed from the developers side. 0 -
I am the developer, the script is in PHP: URL: api.binance.com/api/ [PHP] private function privateRequest($url, $params = [], $method = 'GET') { $params['timestamp'> = number_format((microtime(true) * 1000), 0, '.', ''); $params['recvWindow'> = $this->recvWindow; $query = http_build_query($params, '', '&'); $sign = hash_hmac('sha256', $query, $this->secret); $headers = array( 'X-MBX-APIKEY: ' . $this->key, ); curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($this->curl, CURLOPT_URL, $this->url . $url . "?{$query}&signature={$sign}"); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($this->curl, CURLOPT_ENCODING, ''); if ($method == "POST") { curl_setopt($this->curl, CURLOPT_POST, 1); curl_setopt($this->curl, CURLOPT_POSTFIELDS, array()); } if($method == 'GET'){ curl_setopt($this->curl, CURLOPT_POST, false); } if ($method == 'DELETE') { curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, $method); } //Get result $result = curl_exec($this->curl); if ($result === false) { throw new \Exception('CURL error: ' . curl_error($this->curl)); } // decode results $result = json_decode($result, true); if (!is_array($result) || json_last_error()) { throw new \Exception('JSON decode Error'); } return $result; }[/PHP] 0 -
Check server logs, also in Chrome developers, you should be able to get network diagnosis to see what exactly is hanging and where. Then look at the script and output to a log to show progress at key points to help narrow down where the bottle neck is occurring or what part of the script is failing. 0 -
The script works very well on my localhost and on another server, I honestly do not know how to find the problem, I've been struggling for more than 10 hours to solve this. What logs do you tell me to check for in the WHM or Cpanel panel? 0 -
You'll just have to figure out where the script is being held up. There's not really a golden goose that tells you how to do that. What URL are you posting to? Is that server responding accordingly? 0 -
If works on local host and other server, then could be something e.g. firewall or other blockage. Check error logs in cpanel and whm, if you use CSF disable it temporarily etc... double check settings in your script config - if you moved from localhost, make sure you've connected it properly - triple check if you're tired (10 hrs on it, seems a long time!) good luck. 0 -
The problem was in my script, a function that called the API before the main request and was being blocked. 0 -
Hi @Vinicius Aquino I'm glad to see you were able to identify the cause of the issue! Thanks for updating us here as well. 0
Please sign in to leave a comment.
Comments
8 comments