rferro / plnx

Unofficial Poloniex API client, with public/private methods and push.
http://rferro.github.io/plnx
46 stars 12 forks source link

When a timeout happen an error should be passed to the callback or a retry should happen automatically? #1

Closed hems closed 8 years ago

hems commented 8 years ago

Sometimes the API timeout, for instance when calling returnOrderBook.

I would expect this to come back as "error" on my callback or instead to have a retry setting that would allow the method to automatically retry before calling the error.

Here is an example of the string that was received on my callback under the "data" parameter: http://pastebin.com/Xz15JsGq

hems commented 8 years ago

I believe you should check res.statusCode, if it's different than 200 than it's an error !?

https://github.com/rferro/plnx/blob/master/src/index.js#L79-L86

rferro commented 8 years ago

I add a statusCode check in request callback. In my tests, the timeout can be in request or in api. For request timeout, the error already in callback. And for api timeout, the statusCode check fix the problem. Tks hems!

hems commented 8 years ago

:8ball: would appreciate if you bump the version

rferro commented 8 years ago

version 0.0.5 published in npm