
Fixing "Error: connect ETIMEDOUT ..." for SteemJS below 0.7.0 (NodeJS)
Right now the latest steem-js version on npm is 0.6.7 and default RPC server is still https://steemd.steemit.com. So it will not work, because it is an old uri.
The new RPC server URI is https://api.steemit.com and we need to change it manually.
We could do it programmatically in our script, but there is problem with that:
const { Steem } = require("steem").api;
const steem = new Steem({url: "https://api.steemit.com"});
steem.streamOperations(function _streamOperations(err, operation) {
if (err) throw err;
console.log('operation:', operation) // this will work fine
});
broadcast.voteAsync(POSTING_KEY, ACCOUNT, "accountname", "identifier-of-the-post", 10000)
.then(res => console.log(res))
.catch(err => console.error(err)); // this will error
broadcast module uses default steemApi configuration, so it will try to connect to https://steemd.steemit.com and ETIMEDOUT error will be thrown. So if we need a vote functionality we need to make https://steemd.steemit.com as default url manually.
There is two solutions for this.
- Install steem-js module directly from github https://github.com/steemit/steem-js
or - Edit file
node_modules/steem/config.js. Puthttps://api.steemit.cominurlfield. You will get config like this:
{
"transport": "ws",
"websocket": "wss://steemd.steemit.com",
"websocketdev": "wss://steemd.steemitdev.com",
"uri": "https://steemd.steemit.com",
"url": "https://api.steemit.com",
"dev_uri": "https://steemd.steemitdev.com",
"stage_uri": "https://steemd.steemitstage.com",
"address_prefix": "STM",
"chain_id": "0000000000000000000000000000000000000000000000000000000000000000"
}
You can change uri and transport field, if you wish, instead of url. But it is not necessary, because after updating to 0.7.0 this hack will not be needed.
Leave Fixing "Error: connect ETIMEDOUT ..." for SteemJS below 0.7.0 (NodeJS) to:
Read more #steemdev posts
Best Posts From cron
We have not curated any of cron's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From cron
- How to create account with delegation using steemconnect.com
- When you thought you had $5 but then you check your account and you actually have $17.29
- Fixing "Error: connect ETIMEDOUT ..." for SteemJS below 0.7.0 (NodeJS)
- Flagging is an act of violence and it is not profitable. Why do it?
- Try busy.org. Seriously!
- Fighting phase - begin!
- 2FA: Two Factor Authentication - Computerphile
- Cellphones & Big Data - Computerphile
- Why C is so Influential - Computerphile
- Coding Tech: Code IS NOT Poetry