Dear Volumionauts,
I investigated the WebSocket issue affecting gpio-buttons (and likely rotary-encoder) on Volumio 4. Here are the findings:
Problem
Volumio 4’s package.json declares socket.io 2.3.0, but the actually installed version is 1.7.4:
volumio@hanger:~$ cat /volumio/node_modules/socket.io/package.json | grep version
"version": "1.7.4",
The gpio-buttons plugin specifies "socket.io-client": "^2.3.0" which npm resolves to 2.5.0. This creates a protocol mismatch:
- Server socket.io 1.7.4 uses socket.io-parser 2.3.1
- Client socket.io-client 2.5.0 uses socket.io-parser 3.3.4
Parser 3.x cannot decode parser 2.x messages. When the server sends any response (pushState, etc.), the client crashes:
Error: invalid payload
at decodeString (socket.io-parser/index.js:355:13)
The callMethod actually reaches the server and executes - logs confirm this. But the client socket dies on the response, so all subsequent button presses fail silently.
Why it worked on Volumio 3
Node 14 likely had different npm resolution behavior, or the installed socket.io-client version happened to match. The key issue is the mismatch between declared (2.3.0) and actual (1.7.4) server versions. Alternatively - module declarations in package.json.
Fix
Change package.json from:
"socket.io-client": "^2.3.0"
To:
"socket.io-client": "1.7.4"
Tested and confirmed working - no more crashes, pushState events received properly.
Affected plugins
Any plugin using socket.io-client ^2.x will have this issue:
- gpio-buttons
- rotary-encoder (likely)
- Any other plugin making WebSocket calls
@tomatpasser @Darmur @Wheaten - Do you want to push this fix, or shall I submit a PR? Happy to help either way.
Kind Regards,