Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitstamp loadMarkets() fails: Parse Error #5149

Closed
redwoz opened this issue May 20, 2019 · 12 comments
Closed

bitstamp loadMarkets() fails: Parse Error #5149

redwoz opened this issue May 20, 2019 · 12 comments
Assignees

Comments

@redwoz
Copy link

redwoz commented May 20, 2019

  • OS: Ubuntu 16.04
  • Programming Language version: Node.JS v12.2.0
  • CCXT version: 1.18.551
  • Exchange: bitstamp
  • Method: loadMarkets()
> node
Welcome to Node.js v12.2.0.
Type ".help" for more information.
> const ccxt = require('ccxt')
undefined
> let exapi = new ccxt['bitstamp']()
undefined
> exapi.verbose = true
true
> exapi.loadMarkets()
fetch:
 bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ 
Request:
 {} 
 undefined 

Promise { <pending> }
> (node:26246) UnhandledPromiseRejectionWarning: Error: bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ system request to https://www.bitstamp.net/api/v2/trading-pairs-info/ failed, reason: Parse Error
    at /x/y/z/node_modules/ccxt/js/base/Exchange.js:472:35
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:26246) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

> 

browsing to https://www.bitstamp.net/api/v2/trading-pairs-info/ via Chrome:

[{"base_decimals": 8, "minimum_order": "5.0 USD", "name": "LTC/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "ltcusd", "description": "Litecoin / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "ETH/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "ethusd", "description": "Ether / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "XRP/EUR", "counter_decimals": 5, "trading": "Enabled", "url_symbol": "xrpeur", "description": "XRP / Euro"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "BCH/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "bchusd", "description": "Bitcoin Cash / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "BCH/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "bcheur", "description": "Bitcoin Cash / Euro"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "BTC/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "btceur", "description": "Bitcoin / Euro"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "XRP/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "xrpbtc", "description": "XRP / Bitcoin"}, {"base_decimals": 5, "minimum_order": "5.0 USD", "name": "EUR/USD", "counter_decimals": 5, "trading": "Enabled", "url_symbol": "eurusd", "description": "Euro / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "BCH/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "bchbtc", "description": "Bitcoin Cash / Bitcoin"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "LTC/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "ltceur", "description": "Litecoin / Euro"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "BTC/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "btcusd", "description": "Bitcoin / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "LTC/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "ltcbtc", "description": "Litecoin / Bitcoin"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "XRP/USD", "counter_decimals": 5, "trading": "Enabled", "url_symbol": "xrpusd", "description": "XRP / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "ETH/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "ethbtc", "description": "Ether / Bitcoin"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "ETH/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "etheur", "description": "Ether / Euro"}]
@kroitor kroitor self-assigned this May 20, 2019
@kroitor
Copy link
Member

kroitor commented May 20, 2019

@redwoz hi! What's your location? It is known to block some countries, for example, not accessible from Russia, so, i'm using it with a proxy. Have you tried with a proxy, btw?

@kroitor
Copy link
Member

kroitor commented May 20, 2019

(node:26246) UnhandledPromiseRejectionWarning: Error: bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ system request to https://www.bitstamp.net/api/v2/trading-pairs-info/ failed, reason: Parse Error

↑ This is actually a HTTP response text received from the exchange, saying that the parseError has happened on their side (we don't have such a message anywhere inside the code of the lib). So, it depends on factors outside of the codebase, probably your location/headers or some other cause. Will need some time to reproduce and resolve this.

@houtenbos
Copy link

houtenbos commented May 24, 2019

I've got the same error after updating node to v12 from v11.

OS: Mac Os 10.14
Programming Language version: Node.JS v12.3.1 & v11.15.0
CCXT version: 1.18.571
Exchange: bitstamp
Method: loadMarkets()

Test code:


const userConfig = require('./user_config.json');


const settings = {
    enableRateLimit: true,
    apiKey: userConfig.bitstamp.keys[0],
    secret: userConfig.bitstamp.secrets[0],
    uid: userConfig.bitstamp.uids[0],
    nonce: Date.now,
    verbose: true
};

const client = new ccxt.bitstamp(settings);


const loadMarkets = async function(){
    try{
        console.log(await client.loadMarkets());
    }
    catch(err){
        console.log(err);
    }
}
loadMarkets();

Output Node 11:
fetch:
bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/
Request:
{}
undefined

handleRestResponse:
bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ 200 OK
Response:
{ 'Access-Control-Allow-Headers':
'x-requested-with, Content-Type, origin, accept, cache-control',
'Access-Control-Allow-Methods': 'POST, GET',
'Access-Control-Allow-Origin': '*',
'Cache-Control': 'max-age=0',
'Content-Language': 'en',
'Content-Security-Policy-Report-Only':
"default-src 'self' 'unsafe-inline' 'report-sample'; connect-src 'self' wss://ws.pusherapp.com wss://ws.bitstamp.net *.pusher.com *.trackjs.com *.google-analytics.com stats.g.doubleclick.net ; font-src 'self' data: fonts.gstatic.com www.google.com ; frame-ancestors 'self'; frame-src 'self' pixel-a.basis.net 8720977.fls.doubleclick.net *.ledgerwallet.com *.google.com www.googletagmanager.com pixel.sitescout.com ctpe.net ; img-src * data:; report-uri /api/report-csp/; script-src 'self' 'unsafe-inline' js-agent.newrelic.com *.google-analytics.com *.pusher.com d3dy5gmtp8yhk7.cloudfront.net www.googleadservices.com www.googletagmanager.com www.gstatic.com www.recaptcha.net code.highcharts.com/stock/highstock.js bam.nr-data.net ; style-src 'self' 'unsafe-inline' fonts.googleapis.com",
'Content-Type': 'application/json',
Date: 'Fri, 24 May 2019 09:31:05 GMT',
Expires: 'Fri, 24 May 2019 09:31:05 GMT',
'Last-Modified': 'Fri, 24 May 2019 09:31:05 GMT',
Server: 'Apache',
'Strict-Transport-Security': 'max-age=63072000; includeSubDomains',
Vary: 'Authorization,Accept-Language',
'X-Frame-Options': 'SAMEORIGIN',
'X-Xss-Protection': '1; mode=block',
'Transfer-Encoding': 'chunked',
Connection: 'Close',
'Set-Cookie': '___utmvbPEumyLc=OZb XiIOKalV: EtP; path=/; Max-Age=900',
'X-Iinfo':
'4-40258791-40258821 NNNN CT(0 0 0) RT(1558690265182 100) q(0 0 0 -1) r(1 1) U2',
'X-Cdn': 'Incapsula',
'Content-Encoding': 'gzip' }
[{"base_decimals": 8, "minimum_order": "5.0 USD", "name": "LTC/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "ltcusd", "description": "Litecoin / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "ETH/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "ethusd", "description": "Ether / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "XRP/EUR", "counter_decimals": 5, "trading": "Enabled", "url_symbol": "xrpeur", "description": "XRP / Euro"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "BCH/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "bchusd", "description": "Bitcoin Cash / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "BCH/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "bcheur", "description": "Bitcoin Cash / Euro"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "BTC/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "btceur", "description": "Bitcoin / Euro"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "XRP/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "xrpbtc", "description": "XRP / Bitcoin"}, {"base_decimals": 5, "minimum_order": "5.0 USD", "name": "EUR/USD", "counter_decimals": 5, "trading": "Enabled", "url_symbol": "eurusd", "description": "Euro / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "BCH/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "bchbtc", "description": "Bitcoin Cash / Bitcoin"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "LTC/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "ltceur", "description": "Litecoin / Euro"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "BTC/USD", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "btcusd", "description": "Bitcoin / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "LTC/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "ltcbtc", "description": "Litecoin / Bitcoin"}, {"base_decimals": 8, "minimum_order": "5.0 USD", "name": "XRP/USD", "counter_decimals": 5, "trading": "Enabled", "url_symbol": "xrpusd", "description": "XRP / U.S. dollar"}, {"base_decimals": 8, "minimum_order": "0.001 BTC", "name": "ETH/BTC", "counter_decimals": 8, "trading": "Enabled", "url_symbol": "ethbtc", "description": "Ether / Bitcoin"}, {"base_decimals": 8, "minimum_order": "5.0 EUR", "name": "ETH/EUR", "counter_decimals": 2, "trading": "Enabled", "url_symbol": "etheur", "description": "Ether / Euro"}]

Output Node 12:
fetch:
bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/
Request:
{}
undefined

ExchangeNotAvailable [Error]: bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ system request to https://www.bitstamp.net/api/v2/trading-pairs-info/ failed, reason: Parse Error
at /Users/lhoutenbos/Documents/ccxt error/node_modules/ccxt/js/base/Exchange.js:451:35
at processTicksAndRejections (internal/process/task_queues.js:89:5) {
constructor: [Function: ExchangeNotAvailable]
}

@kroitor
Copy link
Member

kroitor commented Jun 4, 2019

@houtenbos do you still have this error and what's your version of CCXT ?

@houtenbos
Copy link

@kroitor I have still the same error when running the script now with:
node: v12.4.0
ccxt: 1.18.630

@kroitor
Copy link
Member

kroitor commented Jun 5, 2019

@houtenbos which npm do you use to install it for node11 and node12 ? Is it the same executable? Have you tried a clean tmp project reinstall under node12 ? I didn't have the time to test it with node12 on my side yet, but hope to get to it asap.

@frosty00
Copy link
Member

frosty00 commented Jun 5, 2019

works for me jfyi

@kroitor
Copy link
Member

kroitor commented Jun 5, 2019

@frosty00 yep, i think this is setup-specific or user-specific.

@houtenbos would be great if you could try it on a clean setup to verify it, unfortunately, can't reproduce it yet.

@kroitor
Copy link
Member

kroitor commented Jun 5, 2019

I've reproduced it on my side with Node 12.2, apparently, bitstamp doesn't like requests without a user-agent, so I've added a chrome user-agent, the fix will arrive in 1.18.633 in 20 minutes.

@kroitor kroitor closed this as completed in eda2d24 Jun 5, 2019
@shussekaido
Copy link

This error still persists with Node 12 even with the user agent in the header. It goes away when using Node 11.

fetch:
 bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ 
Request:
 {
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' +
    'AppleWebKit/537.36 (KHTML, like Gecko) ' +
    'Chrome/62.0.3202.94 Safari/537.36'
} 
 undefined 

(node:13605) UnhandledPromiseRejectionWarning: ExchangeNotAvailable: bitstamp GET https://www.bitstamp.net/api/v2/trading-pairs-info/ system request to https://www.bitstamp.net/api/v2/trading-pairs-info/ failed, reason: Parse Error
    at /Users/den/code/hems-node/node_modules/ccxt/js/base/Exchange.js:410:35

Error confirmed with:
Node 12.6.0 CCXT 1.18.941
Node 12.2.0 CCXT 1.18.633

@shussekaido
Copy link

message: 'request to https://www.bitstamp.net/api/v2/trading-pairs-info/ failed, reason: Parse Error',
  type: 'system',
  errno: 'HPE_INVALID_HEADER_TOKEN',
  code: 'HPE_INVALID_HEADER_TOKEN'

#4486
nodejs/node#27711
nodejs/node#28468

@kroitor
Copy link
Member

kroitor commented Jul 20, 2019

@shussekaido thx, this is very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants