Closed ezio-melotti closed 10 months ago
I fixed this in #446:
Without an additional websocket lib, our socketio connection relies on long polling. Starting from
python-engineio
4.7.1,simple-websocket
has been added, but it seems to have issues withgevent
/gunicorn
/flask
.gevent-websocket
seems to work fine.
We should still look into having stricter CORS checks.
socketio
supports two types of transport: websockets and HTTP long-polling:I noticed that when using `simoc-sam` locally, the transport is automatically upgraded to use websockets (click to see screenshot).
![image](https://user-images.githubusercontent.com/25624924/206867701-6b115790-4ac0-4851-beea-8e9238274ec8.png)This however doesn't happen for the sim backend. I spent some time investigating and it seems likely that we have some misconfiguration in both
nginx
(used locally and on beta) andtraefik
(used on GCP).The
socketio
docs have a section about sockets stuck in HTTP long-polling that link to another page with a recommendednginx
configuration. However we already have something similar inhttps://github.com/overthesun/simoc/blob/87dbc5c1085e37553fcc494ff04f41c02f9e75c9/nginx/proxy_ws_params#L1-L6
which is then imported in
https://github.com/overthesun/simoc/blob/87dbc5c1085e37553fcc494ff04f41c02f9e75c9/nginx/simoc_nginx.conf.jinja#L75-L79
even though it doesn't seem to work.
The
traefik
config files don't seem to mention websockets.I also noticed that we are disabling CORS checks on the sim backend, so once we fixed these issues we should look into updating this with something stricter: https://github.com/overthesun/simoc/blob/87dbc5c1085e37553fcc494ff04f41c02f9e75c9/simoc_server/views.py#L34-L35
I also tried/investigated other things:
simoc-web
) libraries are up to datevue-socket.io-extended
but Vue3 support is still in alpha and the repo hasn't been updated in over a year.vue-socket.io
seems to support Vue2 too, with only basic Vue3 support from over a year ago. Both packages seems unnecessary.http
orws
doesn't seem to mattervite.config.js
are not the cause of the issue, since they should only apply to the local dev server, but might need to be tweaked while testing locally. Thevite
docs have an example about proxing websockets.