mafintosh / hyperdb

Distributed scalable database
MIT License
754 stars 75 forks source link

Keep connection alive? #168

Open jmul-dev opened 5 years ago

jmul-dev commented 5 years ago

Hello everyone,

I notice that writing data to hyperdb that is connected to remote peers (using discovery-swarm) seems to be taking a very long time and most of time will even fail if the node has been sitting idle for a long time.

Is there a way to keep the connection alive? It's still showing there are peers connected tho.

Thanks!

joehand commented 5 years ago

Hmm, are you passing {live: true} to the replication streams? https://github.com/mafintosh/hyperdb#var-stream--dbreplicateoptions

jmul-dev commented 5 years ago

Hey @joehand , thanks for replying.

Yes, I am. Any other suggestion?

joehand commented 5 years ago

That should be enough. Are the streams closing/erroring? Or do they remain open and it is another issue perhaps...?

stream.on('close', onclose)
stream.on('end', onclose)

function onclose (err) {
  console.log('onclose')
  if (err) console.error(err)
}