Skip to content
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

Add support for Socket.IO v2.x #132

Open
armoha opened this issue Nov 22, 2021 · 4 comments
Open

Add support for Socket.IO v2.x #132

armoha opened this issue Nov 22, 2021 · 4 comments
Labels
feature New feature or request

Comments

@armoha
Copy link

armoha commented Nov 22, 2021

... and therefore revision 4 of Socket.IO protocol and revision 3 of Engine.IO protocol, behind feature gate I suppose.
The v3 server can communicate with v2 clients, but v3 client can't connect to a v2 server.

I'm still learning Rust and Socket.IO but I'd like to contribute if this seems good first issue,

@1c3t3a
Copy link
Owner

1c3t3a commented Nov 22, 2021

Yeah makes sense! I appreciate every contribution :) You can basically fully lean on the current implementation and try to retrofit the changes made to the protocol. A feature flag definitely makes sense, especially regarding the switch in ping and pong packets. As there are currently ongoing changes to the crate, it might make sense to sync with @nshaaban-cPacket on when and how it would make sense to implement this. When you run into questions don't hesitate to ask, I am happy to help!

@1c3t3a 1c3t3a added the feature New feature or request label Nov 22, 2021
@ctrlaltf24
Copy link
Collaborator

ctrlaltf24 commented Nov 22, 2021

main is available to any and all contributions! No synchronization needed, happy to answer questions/point you in the right direction though. As for how to implement this, feature flag make sense (will require some changes to CI), as well as try to keep all the protocol specific logic in one (or a couple) places so we're not stepping on each other's toes and accidentally break each other's code.

I'm still learning Rust

No issues at all, we're all still learning! Always learning! FYI, I've setup a VSCode devcontainer for Socket.IO, if you use VSCode + Docker, it can setup all the project dependencies and CI with a couple clicks.

@RyanWongGithub
Copy link

I'm glad the author can help, I would like to know how to modify this existing code to support engin protocol 3? @1c3t3a

@blinry
Copy link

blinry commented Feb 6, 2025

Hey :) I really wanted support for Socket.IO v2.x (my use case is connecting to Hedgedoc from Ethersync), so I hacked it in!

You can find the result in the socketio-v2 branch of my fork: https://github.com/blinry/rust-socketio. The diff is here.

Target versions

The versioning scheme in the Socket.IO universe seems a bit confusing. To be clear, this implements:

  • The Socket.IO protocol version 4
  • which uses Engine.IO protocol version 3 under the hood
  • both of which are used in the Javascript Socket.IO packages of version 2.x

You'll need this modified client to speak with a Socket.IO server with a npm package version 2.x, see this compatibility table.

Status

I've only touched the async interface, and done the minimal amount of work to support my use case.

Polishing this for inclusion in this crate would require at least the following things:

  • Put all changes behind a feature flag (socketio-v2?), and keep the current functionality when it's not enabled.
  • Properly implement the reversed heart beat mechanism
    • Implement the mechanism in the engineio layer, instead of in the socketio layer (requires some refactoring).
    • Respect the actual timeout setting of the connection, instead of using 5 seconds.
    • Disconnect when the server doesn't pong our ping.
  • Make sure that the sync client also gets the adaptions I've done for the async client.
  • Update the documentation.

Doing these things will not be my current priority. I'd be really happy if someone would pick it up, though, and I'm also willing to offer support in doing so!

However, even in its current state, I thought it might be useful for other folks! (Pinging @armoha @km1chno @RyanWongGithub @mortenlj)

Usage

To use this fork, put the following in your Cargo.toml:

rust_socketio = { git = "https://github.com/blinry/rust-socketio", branch = "socketio-v2", features = ["async"] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants