Unpipe a mux-demux stream.
Industrial opened this issue · 4 comments
Hi.
I'm trying to create a server (https://github.com/Industrial/id-brain) that keeps a number of CRDT
documents synchronized between clients. I'm using mux-demux
to wrap multiple crdt.Doc
streams in one net.Socket
.
I want the clients to automatically reconnect so I'm using https://github.com/juliangruber/reconnect-core for that.
When the connection drops, I want to unpipe the mux-demux
stream from the net.Socket
so that in the mean time the CRDT documents are still usable (and their streams piped into the now stale mux-demux
). and when a new connection is established I can just duplex pipe the mux-demux
into the new stream and CRDT resynchronizes.
The problem I'm having is that I'm not seeing a .unpipe()
on a MuxDemux()
.
you shouldn't need to .unpipe()
, just create new doc streams for every new connection and let the node streams implementation close stale streams for you
Ah, right. Thanks.
On Sep 12, 2014 11:46 AM, "Julian Gruber" notifications@github.com wrote:
you shouldn't need to .unpipe(), just create new doc streams for every
new connection and let the node streams implementation close stale streams
for you—
Reply to this email directly or view it on GitHub
#32 (comment)
.
@juliangruber is correct. @Industrial crdt (which is a subclass of scuttlebutt) streams should not be repiped. They send headers when a new connection is made, and this will not happen when a stream is reused, so you need to call .createStream() again.
Should have closed this long ago.