-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handling disconnect/reconnect #42
Comments
unexcepted disconnection is on the inner muxdemux streams, fixing that probably needs a pull-request to multilevel. it's emitted when the outer stream has ended/closed/errors, but there are inner streams that have not yet ended, but can no longer send any data because the parent stream is dead. |
ok i've figured why I can't seem to catch this error, it's coming out of the livestream. This fixes it: ...
reconnect(function(con) {
con.pipe(db.createRpcStream()).pipe(con)
db.liveStream().on('data', function(message) {
console.log('message', message)
}).on('error', function() {
// ignore error I guess?
})
})
.connect('/engine') Perhaps there's some way I can shield the db from disconnections/reconnections altogether? |
the problem is that ideally the livestream would be reconnect aware, but currently isn't. So on error you should create a new live stream. |
@juliangruber what needs to be added to livestream to make it reconnect aware? |
oh damn i forgot it's internally only using streams for initial data, not for live updates. hmm maybe we could emit |
so, the thing with reconnect is that there is multiple ways you could resume a stream, for example, if you have an append only data stream, that is very easy to resume. But if you have an non-appending data source, and you are streaming it live, then you'd need to be a bit more clever to resume... you could cache some of the recent updates, and resend them if the timeout is short. But if the timeout was longer, you'll just have to resend all the data, and handle it immutably (or you could filter it on the server, if there are timestamps in the data) This is really the problem, is there is no way you could do reconnections in general. it's coupled to the style of data that you have. What kind of data do you have? |
okay: i have an idea for this. we make a small extension to this function wraps the stream call on the client, so that it can remember what ever it needs to reconnect (on that type of stream/data) it might look like this: methods: {
liveStream: {
type: 'readable',
reconnect: function (data, args) {
//this is called on each piece of data that comes out of the stream.
//the function should look at the data, and then update the args,
//which will be the args passed to the new instance of the stream that is created to reconnect.
//e.g.
var opts = args[0] //[{start, end}
opts.start = data.key
return args
}
}
} methods that are lacking a reconnect method should emit an error instead, |
I am getting a Update: it would seem that for the case I am seeing, I'm getting a |
I can't seem to make reconnection work simply. This issue is probably a continuation of #9.
In the multilevel server/client there's a
MuxDemux({error: true})
introduced by @soldair, presumably as part of getting reconnection to work (though I can't find the issue/PR where this change was introduced).Curiously, this change actually breaks my use of reconnect with multilevel? If I pull out this
error: true
, reconnection works as expected. Also not sure where to even attach the error event listener to capture the "unexpected disconnection" error.Sample:
The text was updated successfully, but these errors were encountered: