RE: Fixing "Error: connect ETIMEDOUT ..." for SteemJS below 0.7.0 (NodeJS)

You are viewing a single comment's thread from:

Fixing "Error: connect ETIMEDOUT ..." for SteemJS below 0.7.0 (NodeJS)

in steemdev •  7 years ago 

When I encounter this, this is what I do:


function execute() {
    steem.api.streamOperations((err, results) => {
        return new Promise((resolve, reject) => {
            if (err) {
                console.log("Unable to stream operations %s", err)
                return reject(err)
            }
            return resolve(results) // results [ "operation name", operation:{} ]
        })
        .spread((operation_name, operation) => {
            switch(operation_name) {
                case "comment":
                    return processComment(operation);
                break;
                default:
            }
        })
        .catch((err) => {
            // Probably lost connection with websocket. Restart communication.
            execute();
        });
    });
}

Notice, I just push it back onto the stack.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Great information here... will definitely look closer at the code when i can get on my laptop... thx a bunch