Open wedebe opened 3 years ago
Hi @wedebe , i see no real benefit in performance or traffic if we use websockets for single requests. Websockets will be a good solution if you have triggered changes like push notifications. But these trigger needs to implemented on server side. This can cause performance issues.
Here are some examples. -> Server : https://autobahn.readthedocs.io/en/latest/websocket/programming.html
Let me try a test version.
Hi @wedebe , i see no real benefit in performance or traffic if we use websockets for single requests. Websockets will be a good solution if you have triggered changes like push notifications. But these trigger needs to implemented on server side. This can cause performance issues.
Here are some examples. -> Server : https://autobahn.readthedocs.io/en/latest/websocket/programming.html
The benefit would by far apply to the client-side (web browser/mobile app), being able to notify clients of status change (power state/volume & channel change/signal strength etc.), rather than constant, periodic polling.
Another request from quite some time ago: https://forums.openpli.org/topic/46664-enigma2-websocket/
https://github.com/E2OpenPlugins/e2openplugin-OpenWebif/tree/websocket
NOT TESTET!!!
Thanks!
Fixed typos #1323
Currently at
Plugin Extensions/OpenWebif failed to load: No module named 'autobahn'
Traceback (most recent call last):
File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 56, in readPluginList
plugin = my_import('.'.join(["Plugins", c, pluginname, "plugin"]))
File "/usr/lib/enigma2/python/Tools/Import.py", line 2, in my_import
mod = __import__(name)
File "/usr/lib/enigma2/python/Plugins/Extensions/OpenWebif/plugin.py", line 36, in <module>
from Plugins.Extensions.OpenWebif.httpserver import HttpdStart, HttpdStop, HttpdRestart
File "/usr/lib/enigma2/python/Plugins/Extensions/OpenWebif/httpserver.py", line 35, in <module>
from Plugins.Extensions.OpenWebif.controllers.root import RootController
File "/usr/lib/enigma2/python/Plugins/Extensions/OpenWebif/controllers/root.py", line 44, in <module>
from Plugins.Extensions.OpenWebif.controllers.ws import webSocketServer
File "/usr/lib/enigma2/python/Plugins/Extensions/OpenWebif/controllers/ws.py", line 23, in <module>
from autobahn.twisted.websocket import WebSocketServerProtocol, WebSocketServerFactory
ModuleNotFoundError: No module named 'autobahn'
We need autobahn on the feed and this works only on python3! So we should exclude this on python2. I will check this.
We need autobahn on the feed and this works only on python3! So we should exclude this on python2. I will check this.
We can fallback to less frequent GET
request polling when a websocket connect fails. (Users who don't update their e2 image shouldn't expect the very best experience anyway).
yes why, not the classic UI has also a higher timeout for the status info But the websockets implementation takes a while.
autobahn is on the feed soon
autobahn is on the feed soon
Confirmed now available.
Now getting ModuleNotFoundError: No module named 'voluptuous'
This is a special module to create/validate the schema and can be done differently. https://alecthomas.github.io/voluptuous/docs/_build/html/voluptuous.html#
REQUEST_BASE_SCHEMA = vol.Schema({
vol.Required('id'): int,
})
BASE_MESSAGE_SCHEMA = REQUEST_BASE_SCHEMA.extend({
vol.Required('type'): vol.Any(
TYPE_AUTH,
TYPE_PING
)
}, extra=vol.ALLOW_EXTRA)
AUTH_MESSAGE_SCHEMA = REQUEST_BASE_SCHEMA.extend({
vol.Required('type'): TYPE_AUTH,
})
BUT.. as i said. The real benefit for websockets are push notifications. The push trigger source must be enigma.
Enigma2 triggers the a function in OWF if something new data is available and this function calls the websocket push to the client. This is such a trigger.
OpenWebif (modern ui) currently sends frequent
get
requests to retrieve status and signal data.I'd love to request a test build with a websockets server implementation installed for testing, if possible, please.
(I see there's a
libqt5websockets
in package manager but can't find how to hook it into controllers/web.py)Further info The WebSocket API (WebSockets) - MDN