PHP Binance loadMarkets() | Warning: count(): Parameter must be an array or an object that implements Countable
See original GitHub issue- OS: Herkoku stack 20
- Programming Language version: PHP 7.4.x
- CCXT version: 1.40.80
$classname = '\\ccxt\\binance';
$ccxtExchange = new $classname($options);
$ccxtExchange->enableRateLimit = true;
if ($loadMarkets) {
$ccxtExchange->loadMarkets(); <= The ErrorException was triggered here.
}
ErrorException
Warning: count(): Parameter must be an array or an object that implements Countable
/app/vendor/ccxt/ccxt/php/binance.php in ccxt\binance::fetch_markets at line 725
$markets = $this->safe_value($response, 'symbols');
$result = array();
for ($i = 0; $i < count($markets); $i++) { <= The ErrorException occurred here.
$market = $markets[$i];
It seems that Binance did not send a correct response and therefore this loop failed. I think it would be good if there would be a check on $markets so a more clear Exception could be thrown, or retry? Or whatever is more suitable.
I had a few of these errors in my Sentry logs, so it’s not a big deal, but I think it would be good, if it will be fixed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
count(): Parameter must be an array or an object that ...
When running PHP 7.4, I get the following warning on the logs: PHP Warning: count(): Parameter must be an array or an object...
Read more >PHP 7.3 Warning count(): Parameter must be an array or an ...
PHP 7.3 Warning count(): Parameter must be an array or an object that implements Countable · var_dump($res_remind_att) and see what type it is....
Read more >Exchanges — ccxt 2.4.71 documentation
The ccxt library is a collection of available crypto exchanges or exchange classes. Each class implements the public and private API for a...
Read more >[#MDL-65605] Warning: count(): Parameter must be an array ...
Warning : count(): Parameter must be an array or an object that implements Countable in mod/lesson/import_form.php on line 72. Status: Assignee: Priority:.
Read more >Top 5 ccxt Code Examples - Snyk
loadMarkets() // eslint-disable-next-line no-unused-vars .then((markets) ... Object.keys(exchange.currencies).map(key => (exchange.currencies[key])) : [] ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
sorry for the delay in reply, apparently it is fixed in the latest version CCXT v1.41.81
Array ( [0] => Request: [1] => GET [2] => https://api.binance.com/api/v3/exchangeInfo [3] => Array ( )
) Array ( [0] => Response: [1] => GET [2] => https://api.binance.com/api/v3/exchangeInfo [3] => 200 [4] => [5] => Array ( [Content-Type] => application/json;charset=UTF-8 [Content-Length] => 40225 [Connection] => keep-alive [Date] => Thu, 11 Feb 2021 13:54:41 GMT [Server] => nginx [X-Mbx-Uuid] => c0093a2e-afc4-497d-bdba-b872a3994ec3 [X-Mbx-Used-Weight] => 1 [X-Mbx-Used-Weight-1m] => 1 [Content-Encoding] => gzip [Strict-Transport-Security] => max-age=31536000; includeSubdomains [X-Frame-Options] => SAMEORIGIN [X-Xss-Protection] => 1; mode=block [X-Content-Type-Options] => nosniff [Content-Security-Policy] => default-src ‘self’ [X-Content-Security-Policy] => default-src ‘self’ [X-WebKit-CSP] => default-src ‘self’ [Cache-Control] => no-cache, no-store, must-revalidate [Pragma] => no-cache [Expires] => 0 [Access-Control-Allow-Origin] => * [Access-Control-Allow-Methods] => GET, HEAD, OPTIONS [X-Cache] => Miss from cloudfront [Via] => 1.1 c3f257ad7ec4633c503cd21a690fa4dd.cloudfront.net (CloudFront) [X-Amz-Cf-Pop] => MIA3-C2 [X-Amz-Cf-Id] => 0linntpztL4RQz9SbYvABBSs9HYn7pGaHjf5mBISP1zs30XKddblaw== )
@weerdenburg if you encounter this issue we will need the verbose output to resolve it (https://github.com/ccxt/ccxt/wiki/FAQ#what-is-required-to-get-help)