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

Any schedule for migrating to socket.io 4.x? #139

Closed
lantica opened this issue Jul 28, 2021 · 6 comments
Closed

Any schedule for migrating to socket.io 4.x? #139

lantica opened this issue Jul 28, 2021 · 6 comments

Comments

@lantica
Copy link

lantica commented Jul 28, 2021

The socket.io using now is v 2.x, which means client using v3.x / 4.x will not be able to connect.
I would like to know is there any plan for updating it?

@franciscop
Copy link
Owner

franciscop commented Aug 5, 2021

Sorry no plans at the moment for that, do versions 3.x and 4.x totally break backwards compatibility?

Edit: it seems that we can upgrade at least safely to 3.x on the server side:

Update: As of Socket.IO 3.1.0, the v3 server is now able to communicate with v2 clients. More information below. A v3 client is still not be able to connect to a v2 server though.

@lantica
Copy link
Author

lantica commented Aug 10, 2021

Yes, there is backward compatibility for both v3.x and v4.x server to v2.x client.
However, an option (allowEIO3: true) will be required in order for the backward compatibility.

I have tried just updating the socket-io to v4.1.3 with that option, it seems to be work fine with v2.x client.

@franciscop
Copy link
Owner

franciscop commented Aug 11, 2021

The sockets is the main part of the codebase without tests (I'm not even sure how to approach testing here) so migration is not going to be easy at all to ensure compatibility, specially with how large socket.io API is.

I created a small example for socket.io, and I'll be adding more and more bits (or maybe other examples) to check whether it works as intended both with 2.x and 4.x. Unfortunately I'm limited on time, so the earliest I feel comfortable shipping this is September

If you need it right now, you could do it in a not-too-difficult way:

  1. Disable the official socket plugin with the option { socket: false }
  2. Copy plugins/socket/index.js into your codebase e.g. into ./mycodebase/socket.js
  3. Change the name to newsocket or something different, and update accordingly
  4. Install socket.io 4.x or whichever version you use locally npm i socket.io@4
  5. Update your codebase to use this new plugin. It has the basic config, but also a small router callback, so this should work:
const server = require('server');
const newsocket = require('./mycodebase/socket');

server.plugins.push(newsocket);
server.router.socket = newsocket.router;

server({ router: false }, ...);

I haven't tried this, but AFAIK this should be it so please feel free to report any issue trying to follow these steps.

@kinostl
Copy link
Contributor

kinostl commented Oct 9, 2022

#144 updated this to 4.5

@franciscop
Copy link
Owner

Thanks! I guess we can close this now :)

@franciscop
Copy link
Owner

Note: not released yet, will be released within a couple of days

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

No branches or pull requests

3 participants