steemit / steem-js

Steem.js the official JavaScript library for Steem blockchain
https://www.npmjs.com/package/steem
MIT License
472 stars 225 forks source link

Error: unexpected server response (504) #251

Open Mikepicker opened 7 years ago

Mikepicker commented 7 years ago

Expected behavior

Calling steem.api.getAccountHistory should retrieve information correctly.

Actual behavior

Exception thrown:

Error: unexpected server response (504) at ClientRequest._req.on (/app/node_modules/steem/node_modules/ws/lib/WebSocket.js:656:26) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:474:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23) at TLSSocket.socketOnData (_http_client.js:363:20) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at TLSSocket.Readable.push (_stream_readable.js:134:10) at TLSWrap.onread (net.js:547:20)

How to reproduce

It happens sometimes when calling steem.api.getAccountHistory.

Environment information

Ubuntu, Node v6.11.2, npm v3.10.10

Siko91 commented 7 years ago

I get the same one. I also get 502 errors sometimes. I am running with Ubuntu as well. The problem appears both with Node v4.2.6 and Node v6.11.3

This is how the 502 error looks like:

events.js:160 throw er; // Unhandled 'error' event ^ Error: unexpected server response (502) at ClientRequest._req.on (/home/alex/Desktop/steemitbots/resteem-bot/node_modules/ws/lib/WebSocket.js:656:26) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:474:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23) at TLSSocket.socketOnData (_http_client.js:363:20) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:176:18) at TLSSocket.Readable.push (_stream_readable.js:134:10) at TLSWrap.onread (net.js:547:20)

The 504 error looks pretty much the same as with @Mikepicker

bonustrack commented 7 years ago

Are you both using the default websocket? It might fail sometimes to respond. I recommend to use wss://steemd-int.steemit.com instead.

Siko91 commented 7 years ago

Just tried it out. So far it seems to work fine.

One thing that surprised me, was that the indexes of the history (steem.api.getAccountHistory) are completely different when using wss://steemd-int.steemit.com, compared to the default websocket.

Why is it like that? Is some information filtered in the wss://steemd-int.steemit.com, or did it just start counting later?

Mikepicker commented 7 years ago

It looks way more reliable, thanks @bonustrack. Any chance to write it on the docs?