Skip to main content

POST requests for script are taking 3 minutes

Comments

8 comments

  • sparek-3
    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
  • Vinicius Aquino
    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
  • WorkinOnIt
    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
  • Vinicius Aquino
    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
  • sparek-3
    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
  • WorkinOnIt
    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
  • Vinicius Aquino
    The problem was in my script, a function that called the API before the main request and was being blocked.
    0
  • cPanelLauren
    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.