fix: set default protocol version to 3 to allow backward compatibilit… #616
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.
…y of socket.io-client-swift
socket.io-client-swift libs version <=15.2.0, which uses protocol version 3, do not explicitly add the EIO query parameter at transport initialization. This omission leads the server to treat the client as a client that supports the protocol version 4, previously set as default, which is not correct for those versions of the client lib.
From socket.io-client-swift version v16.0.0 the EIO query parameter is explicitly passed to specify the protocol version supported, but since the allowEIO3 parameter aims to make the server compatible with previous versions which in most of the cases are already used in production and not easily upgradable, it makes more sense to default the EIO version to 3 if not explicitly set by the client since the newer client versions pass the EIO protocol version in query parameters.
The kind of change this PR does introduce
Current behaviour
socket.io-client-swift libs version <=15.2.0 cannot connect due to parsing errors since they are treated as client that support EIO protocol 4 but they supporto EIO protocol 3.
New behaviour
socket.io-client-swift libs version <=15.2.0 are correctly identified as EIO protocol 3 client and can connect correctly
Other information (e.g. related issues)
MOTIVATION: this new version of engine.io is used by the new version of socket.io and have a flag that allow backward compatibility with older client versions that implement EIO protocol version 3, but this is not true in practice since the EIO protocol used is defaulted to 4 if not explicitly indicated in the connection request, as in the case of socket.io-client-swift libs version <=15.2.0. Since is very likely that an update to socket.io from v2 to v3 involves the connection from clients that implements both EIO protocol 3 and 4, it makes sense to maintain the backward compatibility for all the client libs.