Skip to content

Use Socket.io instead of Websockets #775

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

Open
Archmonger opened this issue Jun 25, 2022 · 6 comments
Open

Use Socket.io instead of Websockets #775

Archmonger opened this issue Jun 25, 2022 · 6 comments
Labels
priority-3-low May be resolved one any timeline. type-investigation About research and gathering information

Comments

@Archmonger
Copy link
Contributor

Archmonger commented Jun 25, 2022

Current Situation

Currently, IDOM does not fallback to keep-alive HTTP persistent connections in the event that Websockets are not supported.

Proposed Actions

Utilize replace Websocket connections with the Socket.io API, which fills in this gap.

We will need to use python-socketio for compatibility, likely the same way they do with Tornado.

Related issues

@Archmonger Archmonger added type: feature type-investigation About research and gathering information labels Jun 25, 2022
@Archmonger Archmonger added this to the 2.0 milestone Jun 25, 2022
@rmorshea
Copy link
Collaborator

rmorshea commented Jul 1, 2022

Are there any modern browsers that don't support websockets?

@Archmonger
Copy link
Contributor Author

No - But the issue isn't due to browser support. Reverse proxies are known to sometimes be unstable with Websockets under certain configurations. This issue is compounded when using multiple reverse proxies (ex. Nginx + CloudFlare).

Over in the Organizr group we see these problems fairly frequently. Most of the time it's fixable through configuration, but a lot of web dev communities have moved to using either Signalr or Socket.io just to avoid the constant user support questions.

@Archmonger Archmonger modified the milestones: 2.0, 3.0 Jul 1, 2022
@Archmonger Archmonger added the priority-3-low May be resolved one any timeline. label Feb 14, 2023
@rmorshea rmorshea removed this from the Speculative milestone Feb 21, 2023
@Archmonger
Copy link
Contributor Author

Archmonger commented Apr 29, 2023

Socket.io will result in us only supporting requiring web frameworks that support long-polling HTTP.

But at that point, we may as well axe our websocket-based design and only use long polling HTTP. If we did, it would resolve our file upload problems.

@rmorshea What's your opinion on switching the framework to rely on HTTP long polling? I can draft a proof of concept if you'd like.

@rmorshea
Copy link
Collaborator

rmorshea commented Apr 30, 2023

I think this should be implemented as an independent backend first. Doing so has two benefits:

  1. It will likely expose areas for improvement in how we expect backends to be defined.
  2. It won't have to wait for a 2.0 release.

I'm particularly interested in 1 since, while not practical at the moment, a socket-io backend ought to be able to re-use code from the existing backend definitions since it will only need to provide a new client and _reactpy/stream route. I can imagine a world in which it's possible to swap out the "transport" for a backend - e.g. perhaps a transport could just be an ASGI/WSGI server that's mounted at the appropriate route.

@rmorshea
Copy link
Collaborator

I need to learn more about YJS, but it's possible that we should take the same approach with #826

@Archmonger
Copy link
Contributor Author

Archmonger commented Apr 30, 2023

After looking at python-socketio, the file serialization situation might already be a solved issue?

The javascript socketio supports file transfers, but I have no idea how this interfaces with python-socketio.

EDIT: Looks like it doesn't natively support file uploads. If we can figure out a way to use each framework's HTTP internals to handle file uploads, that is probably best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low May be resolved one any timeline. type-investigation About research and gathering information
Projects
None yet
Development

No branches or pull requests

2 participants