Comments (4)
Looks like you're getting network errors, you need to handle them manually on the streams now (i might add something that handles stream errors in the future though).
You could do something like this (untested)
function run() {
const stream = client.blockchain.createBlockStream()
stream.on('data', (block) => { console.log('block', block) })
stream.on('error', (error) => {
console.log('stream error', error)
})
stream.on('end', () => {
console.log('stream ended, recreating...')
run()
})
}
from dsteem.
Restarting works but it often happens that I'm looking for e.g. an upvote or comment and right when it should be found the connection interrupts. This makes it unreliable. Are you sure that there is no problem with the JSON return? Isn't there something to make it just skip that JSON? And if its possible to output which JSON actually caused the error?
Edit: I've added a bit of commenting to your dsteem code to see what is going on and it seems that instead of json - an html element get's parsed.
undefined:1
<html>
^
SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at IncomingMessage.stream.on (/Users/wolf/Bots/CommentVote/dsteem/lib/utils.js:132:81)
at emitNone (events.js:110:20)
at IncomingMessage.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
from dsteem.
After researching more I found out that this the error.
<html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>
Seems like you were right about network errors. But what is the best way to handle this? Because I'm looking for transactions and if transactions come in while I have that time-out error I'd lose transactions and that's very bad. I'd have to either start searching blocks from the moment it stopped or to watch for them in my transfer history (but is that even possible)?
Oh and by the way I'm using
const stream = client.blockchain.getOperationsStream({mode: dsteem.BlockchainMode.Irreversible});
and not 'createBlockStream' what you had in your example.
from dsteem.
@therealwolf42 try updating to 0.8.1, it should have you seeing much fewer network errors. The new default behaviour is to retry requests for 1 minute. If they timeout you still need to handle the error but should only happen if there's a major outage now
from dsteem.
Related Issues (20)
- runing problem HOT 3
- error
- Demo is not working. Demo should not be using websockets. HOT 3
- Best way to load post comments HOT 1
- Get the block id when streaming the chain HOT 2
- Please create api for get_account_votes
- getOperationsStream() does not stream on mode: BlockchainMode.Latest
- Support for different asset symbols (private blockchains)
- Steem API changes HOT 1
- Change Date.now() to props.time
- client.broadcast.comment does not return a status HOT 3
- [Question] how do you encrypt a transfer memo?
- error node_modules/dsteem/lib/steem/serializer.d.ts(43,43): Error TS2304: Cannot find name 'ByteBuffer'.node_modules/dsteem/lib/steem/serializer.d.ts(43,43): Error TS2304: Cannot find name 'ByteBuffer'.
- One problem on build dsteem
- update_account missing permission parameter HOT 1
- So this project no longer maintained? HOT 1
- Maintainers wanted HOT 5
- Can't use get_reblogged_by
- ReferenceError: regeneratorRuntime is not defined
- Error occuredTypeError: Network request failed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsteem.