-
Notifications
You must be signed in to change notification settings - Fork 450
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
Keep same connection ID when reconnecting #339
Comments
Actually, any current changes to the {
a: 'init',
protocol: 1,
semverProtocol: '1.1.0',
id: this.clientId,
type: types.defaultType.uri
} That way newer clients would know to check for the |
Also, if the above connection flow is correct, then am I right in thinking there's a possible bug where:
Given that there's no initial prompt from the |
Noting here that Alec wrote a test to show the above case, where an issue occurs with a noticeable delay between the client creating the socket and it creating a connection: All the examples and documentation show socket creation -> connection creation being synchronous, so it's not actually an issue today. But it does complicate things if we want to have the client propose a connection id, as Alec notes further above. We then discussed a new init sequence that should work in a backwards-compatible way:
|
We spoke about allowing
Connection
s to keep their existing ID when reconnecting so we can have a persistentsrc
across all ops belonging to an interruptible "session" on a flaky connection.We'd suggested allowing the
Connection
to optionally propose an ID to theAgent
(rather than just always being assigned one). However, if I understand this all correctly, then the connection flow (as it stands) looks something like:Connection
object with this socketAgent
object with this socketConnection
sets it state to'connecting'
until it receives a message from theAgent
Agent
sends an'init'
message, with the client IDConnection
receives the message, sets its ID and sets its state to'connected'
If the above is correct (please correct me if I'm wrong), then the only approach I can think of which would allow the
Connection
to propose an ID — without breaking existing behaviour — would be: propose the ID on creation of the socket, outside of ShareDB (eg as a query string on a websocket URL). This feels like it puts too much onus onto the library consumer, so probably not an acceptable solution?Other approaches would be breaking changes to the connection handshake:
Agent
wait for a message from theConnection
before sending'init'
: breaks when old clients connect to new servers, because theAgent
is waiting for a message it will never receiveConnection
counter-propose its assigned ID: breaks when new clients connect to old servers, because theAgent
doesn't know what to do with the new message, and theConnection
will wait forever for a responseOf course, we could hide this behaviour behind a feature flag if we want to stay on v1, but any changes to the handshake feel like they really belong to this bigger package of work?
Or perhaps the counter-proposal solution could work by checking the
Agent
'sprotocol
version? If it's1
, then we know we can't counter-propose, but if it's2
, then we can? (Or some other semver thing like1.1.0
)The text was updated successfully, but these errors were encountered: