steem-js icon indicating copy to clipboard operation
steem-js copied to clipboard

"Unhandled rejection Error: not opened" when using steem.broadcast.vote

Open drov0 opened this issue 7 years ago • 19 comments

Expected behavior

I have a very small app that basically votes and then unvotes : https://github.com/drov0/Nopebot

It works well, but if I let it run for some time (30-40minutes) then I get an error when I try to call steem.broadcast.vote

Actual behavior

I get exactly this error :

0|main | Unhandled rejection Error: not opened 0|main | at WebSocket.send (/root/Nopebot/node_modules/ws/lib/WebSocket.js:344:18) 0|main | at /root/Nopebot/node_modules/steem/lib/api/transports/ws.js:135:19 0|main | at tryCatcher (/root/Nopebot/node_modules/bluebird/js/release/util.js:16:23) 0|main | at Promise._settlePromiseFromHandler (/root/Nopebot/node_modules/bluebird/js/release/promise.js:512:31) 0|main | at Promise._settlePromise (/root/Nopebot/node_modules/bluebird/js/release/promise.js:569:18) 0|main | at Promise._settlePromiseCtx (/root/Nopebot/node_modules/bluebird/js/release/promise.js:606:10) 0|main | at Async._drainQueue (/root/Nopebot/node_modules/bluebird/js/release/async.js:138:12) 0|main | at Async._drainQueues (/root/Nopebot/node_modules/bluebird/js/release/async.js:143:10) 0|main | at Immediate.Async.drainQueues [as _onImmediate] (/root/Nopebot/node_modules/bluebird/js/release/async.js:17:14) 0|main | at processImmediate [as _immediateCallback] (timers.js:383:17)

How to reproduce

run the code https://github.com/drov0/Nopebot, just put a few steemit articles urls in the form (validate the form a few time), then wait for some time (30-40 minutes) and try to submit another article to the form

Environment information

ubuntu 16.04 nodejs v4.2.6

drov0 avatar Nov 23 '17 10:11 drov0

It might be a problem with the default Steem WebSocket. Try putting this line before you do anything on the Steem network.

steem.api.setOptions({ url: 'wss://node.steem.ws' });

syvb avatar Nov 25 '17 11:11 syvb

Mmmh interesting idea.

Problem is it does not recognizes the other nodes :

wss://node.steem.ws : getaddrinfo ENOTFOUND node.steem.ws node.steem.ws:443 wss://this.piston.rocks : Hostname/IP doesn't match certificate's altnames: "Host: this.piston.rocks. is not in the cert's altnames: DNS:steemit.com, DNS:*.steemit.com"

drov0 avatar Nov 25 '17 15:11 drov0

Same problem

linosorice avatar Nov 28 '17 07:11 linosorice

Take a different websocket.

const steem = require('steem'); steem.api.setOptions({ url: 'wss://steemd-int.steemit.com' });

ghost avatar Dec 12 '17 10:12 ghost

Will try tonight, thanks.

drov0 avatar Dec 12 '17 13:12 drov0

Same problem(s) when using steem.api.getAccounts.

For 'wss://node.steem.ws' and wss://this.piston.rocks I encounter the same as drov0 above

I received a normal response from the default socket and from 'wss://steemd-int.steemit.com' at first. After about 10 minutes I see this...

Unhandled rejection Error: not opened at WebSocket.send

I'm using node v7.9.0 on Ubuntu 14.04.3 LTS. Have tried steem-js ver 0.6.7 and 0.6.10 with the same result.

tdreid avatar Jan 01 '18 22:01 tdreid

Getting the same problem with the default websocket

MrToph avatar Jan 07 '18 20:01 MrToph

In my case it seemed to be a problem with timeout or interruption of the websocket. To make sure it's open and ok I explicitly set the options to the default immediately before calling getAccounts (or broadcast vote, etc)...

steem.api.setOptions({ url: 'wss://steemd.steemit.com' });
steem.api.getAccounts(["ned","null"], function(err, response) {
    if (!err) {
      //render 
    } else {
      //do some err handling
    }
});

Got the error to stop. Not sure whether there's a downside.

tdreid avatar Jan 07 '18 20:01 tdreid

@tdreid the endpoint wss://steemd.steemit.com is not being maintained anymore see related post: https://steemit.com/steemitdev/@steemitdev/last-chance-to-update-steemd-steemit-com-will-be-retired-on-january-6 You should use this endpoint instead https://api.steemit.com.

bonustrack avatar Jan 07 '18 20:01 bonustrack

Guys use this websocket wss://steemd-int.steemit.com The other ones are having troubles and this one i use for my projects and its stable.

ghost avatar Jan 07 '18 20:01 ghost

@bonustrack Thanks! This seems to be the correct solution, i would not use wss://steemd-int.steemit.com either anymore.

MrToph avatar Jan 07 '18 20:01 MrToph

@bonustrack Yes I can confirm as well that wss://steemd-int.steemit.com has issues.

I will try the https://api.steemit.com endpoint and I have no issues for a week I'll close the issue :)

drov0 avatar Jan 11 '18 13:01 drov0

Update : The bug still appears, less often but still does.

drov0 avatar Jan 16 '18 14:01 drov0

Trying to do anything in the API I get the error:

Unhandled rejection Error: getaddrinfo ENOTFOUND steemd.steemit.com steemd.steemit.com:443
    at errnoException (dns.js:50:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
Unhandled rejection Error: getaddrinfo ENOTFOUND steemd.steemit.com steemd.steemit.com:443
    at errnoException (dns.js:50:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
Unhandled rejection Error: getaddrinfo ENOTFOUND steemd.steemit.com steemd.steemit.com:443
    at errnoException (dns.js:50:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)

Am I to understand that the Steemit team discontinued this endpoint and did not update the library they provide...? That would be beyond my belief.

Nantris avatar Jan 17 '18 18:01 Nantris

"That would be beyond my belief." Welcome to steem development :)

drov0 avatar Jan 24 '18 06:01 drov0

Yup. TIL... What a mess.

Nantris avatar Jan 24 '18 21:01 Nantris

For now, you can use https://api.steemit.com because it works. My worker for https://steemcron.com wasn't working until I switched to the endpoint api :)

tikirey avatar Feb 07 '18 14:02 tikirey

this error Unhandled rejection Error: getaddrinfo ENOTFOUND steemd.steemit.com steemd.steemit.com:443 I keep having it on all kind of endpoints. Also tried api.steemit, that from minnowproject and the full node that is runned by reggeamuffin and his group. All those give me the same error.

The services / bot are running fine.. Just once a while this error kicks in

ghost avatar Feb 07 '18 19:02 ghost

(Glad I'm not the only one seeing this... being a bit new to JS api writing, I thought I "missed" something in my code!)

I've run into the same problem, but with something even more interesting. My project attempts to connect to 2 different endpoints - the standard STEEM blockchain as well as the steem.vc testnet blockchain - so "setOptions" runs on almost every call.

When the problem occurs, BOTH endpoints are broken. If it was a websockets problem or a problem with the endpoint itself, I would expect only the live blockchain OR the test blockchain would fail. But when the problem occurs, it fails on BOTH blockchains. Seems that SteemJS is losing track of something that it needs - and once it loses it once, it can't reset without restarting the application.

I should note, also, that it doesn't matter what operation is being done - even obtaining user info. It isn't just voting. It seems any access to the blockchain gets blocked.

No idea what it may be, but hopefully this info can help.

dentm42 avatar Feb 13 '18 16:02 dentm42