Adopt client protocol v2 #499
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
This pull request adopts client Protocol Version 2. The initial motivation described in centrifugal/centrifuge#217 and implementation is in centrifugal/centrifuge#218.
Two important differences in client protocol v2 at the moment are:
v2 client protocol framing changes
This comparison demonstrates well what was changed in client protocol definitions for client protocol v2.
v2 client protocol disconnect behavior changes
Client protocol v2 does not use
Reconnectfield in Disconnect Reason (encoded previously as JSON).Reconnect advice now depends on disconnect Code. The rules described below.
Disconnect codes in range 0-2999 should not be used by a Centrifugo user. Those are reserved for the client-side and transport specific needs. Codes in range >=5000 should not be used also. Those are reserved by Centrifugo.
Client should reconnect upon receiving code in range 3000-3499, 4000-4499, >=5000. For codes <3000 reconnect behavior can be adjusted for the specific transport.
Codes in range 3500-3999 and 4500-4999 are application terminal codes, no automatic reconnect should be made by a client implementation.
Centrifugo users supposed to use codes in range 4000-4999 for creating custom disconnects in proxy handlers.
Backwards compatibility and migration plan
cf_protocol_version=v2URL param to tell server that client speaks v2 protocol version."use_client_protocol_v1": trueso routes will use v1 by default and existing connectors will work fine. To enable using protocol v2 users can set?cf_protocol_version=v2in URL. As soon as all clients migrated to protocol v2 developers can remove option"use_client_protocol_v1": truefrom the configuration. Since this moment?cf_protocol_version=v2may be removed from client connection URLs.use_client_protocol_v1option.When this will be shipped
We intend to merge this for Centrifugo v3.2.0. Centrifugo v4 will be released only when all existing client connectors will support client protocol v2. At the moment we have the following PRs: