zwave-js-ui, nginx, HA websocket issue #2784
Replies: 6 comments 2 replies
-
Never seen such kind of problems, just to be clear, are you speaking about the zwave-js UI websocket or the home hassistant websocket? Is your problem on the z-ui UI side or home assistant side? |
Beta Was this translation helpful? Give feedback.
-
The UI Websocket. I have the HA websocket disabled. |
Beta Was this translation helpful? Give feedback.
-
At first sight it seems to me a cache problem in nginx configuration, I'm not an nginx expert but I know hass addon works without any problem (and it's using nginx) and I also have a working example using nginx |
Beta Was this translation helpful? Give feedback.
-
Your location / matches all requests, and you have websocket headers in there. If you don't need the websocket on / and only on the zigbee/hass/zwavejs parts can probably take it out of there. FWIW, it may be easier to use a separate host header for each. Would make the configs easier to troubleshoot vs having child paths. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I've pinpointed the issue and opened a ticket with Home Assistant - Frontend. In short it's service-worker is caching any http responses with a status of 200. Since socket.io provides the session id in a response with status 200 the data is cached and the correct sid is never recieved by zwavejsui unless the browser is refreshed with the cache being cleared (Shift+F5) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a bit lengthy but here it goes...
I've got a seemingly weird issue with zwave-js-ui and nginx. For whatever reason the websocket connection only works if I CTRL+F5(no-cache reload). If I do a simple F5 refresh afterwards the websocket connection fails.
Digging into this further I've found that on a regular page load/refresh zwave-js-ui or socket.io is returning what seems to be bogus sid and it's always the same sid. If I no-cache refresh a valid sid is returned and the websocket session connects without issue.
I've checked the issue trackers for zwave-js-ui and socket.io as well as done some general web searching to see what I can find. From what I can tell my nginx config should be fine as it does work via CLI via
wscat
and does work on a no-cache reload.My setup is pretty simple but is as follows
Config: https://pastebin.com/YkytXi15
Checking the Firefox dev console on a regular load/reload I see the first request to socket.io via
https://homeassistant.FQDN:8124/_/zwavejs2mqtt/socket.io/?EIO=4&transport=polling&t=OGVHQXK
and it receives the response0{"sid":"QHEjB7LIw5v_fO0rAAEl","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":20000,"maxPayload":1000000}
. The sid in this response is always the same.When I no-cache reload I see the same initial connection but with a valid sid. I can verify the same behavior with
curl
Mid ticket update:
So I've found that zwave-js-ui will work fine until I sign into HA. Once I sign into HA the problematic behavior occurs.
HA URL: https://homeassistant.FQDN:8124/
zwave-js-ui URL: https://homeassistant.FQDN:8124/_/zwavejs2mqtt/
I found that simply adding an extra port (8125) to the nginx config then connecting to zwave-js-ui works perfectly at the URL above until I sign into HA at the URL above.
Is there some sort of cookie or session storage collision going on here?
Beta Was this translation helpful? Give feedback.
All reactions