Can regular network requests be used instead of WebSocket? #3953
Replies: 2 comments
-
|
NiceGUI uses socket.io to implement its WebSocket connection, and it can be configured to use HTTP requests (polling) instead of WebSocket. The main benefits of WebSocket are:
I think Mesop uses HTTP mainly to reduce complexity. I would not be surprised if they switch to websockets in a later version. |
Beta Was this translation helpful? Give feedback.
-
|
If anyone is looking for a way to deploy NiceGUI on AWS, a great option is App Runner. However, App Runner doesn't support WebSockets. By forcing Socket.IO to use long polling instead, you can deploy there without issue: from nicegui import ui, core
core.app.config.socket_io_js_transports = ["polling"]
ui.run(proxy_headers=True, forwarded_allow_ips="*")The proxy_headers and forwarded_allow_ips settings are needed because App Runner terminates TLS and forwards traffic as HTTP — without them, uvicorn doesn't know the client connected over HTTPS. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I have discovered something called Mesop, which is a similar product, but it does not use websocket. Instead, it uses regular GET requests to achieve front-end and back-end communication. Is this method more advantageous than websocket Because in my opinion, websocket is a type of long-term connection that can cause users to idle web tags and occupy our server resources for a long time
Can this technology be integrated into Nicegui
Mesop's experience address: https://google.github.io/mesop/demo/ Here, you can take a look at its communication method
Beta Was this translation helpful? Give feedback.
All reactions