-
Notifications
You must be signed in to change notification settings - Fork 286
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 basic websockets support #1027
Conversation
615d38d
to
24cfdf1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Nice that the the overall amount of non-boilerplate changes was pretty minimal from SSE to WebSocket.
Have you tested on Cloud Run?
I tested it out a bit, mostly with the animation demo and it worked pretty well. I didn't run into the same issues as #981.
It still has the issue of #980 but I think that's resolvable by not deleting the sessions objects right away. Not sure if that's a good long term approach. But I can try to prioritize that fix.
Been a while since I've used socket io, but does socket io still have fallbacks when web sockets are not possible --- I'm assuming not since back in the day web socket support was not in all browsers yet?
And thanks for offering to handle the downstream sync. 🙇🏾 🙇🏾 🙇🏾
Agreed :) our server/channel abstraction ain't too bad :D
I haven't but I'll try to test it out sometime. Theoretically it should work because Cloud Run supports websockets, but I'm not sure if the cutover will work (e.g. a request gets routed to another Cloud Run instance).
Yeah it still has fallback support with HTTP long-polling. We could support making this configurable, although, I think for Mesop, it's probably better to just use the default SSE approach.
|
I see. Yeah I was thinking the long polling probably wouldn't be a great experience (compared to SSE). Would there be a way to disable that fallback? In terms of options from there, I guess we could try to fallback to the Mesop SSE in that scenario. But I do wonder if the behaviors/functionality would diverge too much after a while. So if someone enabled Websockets, then they probably are expecting certain functionality potentially. So the other option is to just sort of fail for those users, but that's also not a great experience (but I imagine web socket support is pretty common nowadays so seems like an uncommon scenario. |
It should be disabled: mesop/mesop/web/src/services/channel.ts Line 169 in 75edeb8
Yeah I think failing is OK. My guess is websockets will be used only in advanced use cases, where the developer should have a good idea of whether its supported. |
Summary of changes:
MESOP_WEBSOCKETS_ENABLED
env var is set to true), then all the subsequent UI requests and responses will happen on a single websocket connection.Notes:
werkzeug
aren't actually introduced in this PR and they only affect Mesop framework developers._requests_in_flight
code.