-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.js 20 problems #907
Comments
I've noticed identical issues but never realized it might be linked to node v18. I tried tracking it down but never got any further than noticing the TTS mp3 files were ok but the http server simply didn't respond sometimes. |
In my case it’s definitely NOT linked to node v18. It’s solely a node v20 issue. |
I think this is related to this global change in Node 20: The Sonos players probably doesn't like keep-alive, and might not properly respond with a Connection: close. The http api will maintain connections and try to send new requests over the old socket and probably confusing the player. Since this only affects requests that happen within 30-90 seconds (not sure what the default timeout is), this might appear random. I'll see if I can reproduce it, I haven't run this project under newer Node.js versions in a long time. |
@jishi this sounds like a good error diagnosis. Please let me know what tests I should conduct in order to narrow down the problem. I’ll find this API extremely helpful! |
@jishi Greetings from Germany. As I am not a javascript resp. programmer professional I have been using ChatGPT for help. Here is what KI suggests: The developer's response provides an insightful explanation of the issue you're experiencing with the node-sonos-http-api under Node.js 20. Here's a breakdown: Key Points in the Response The issue is likely related to the global change in Node.js 20 introduced in the PR #43522, which modified how HTTP connections are handled, particularly with persistent (keep-alive) connections. Sonos players may not handle persistent HTTP connections (keep-alive) correctly. The problem might only occur when requests happen within the time frame that a connection remains open (30–90 seconds, depending on the default keep-alive timeout). This makes the issue seem random and harder to reproduce. Modify the node-sonos-http-api code to ensure that all HTTP requests include a Connection: close header. This forces each request to use a new connection, avoiding potential conflicts with keep-alive. javascript Temporarily downgrade to Node.js 18 or a version before Node.js 20 to see if the problem disappears. This would confirm that the keep-alive change is the root cause. Ensure all dependencies in node-sonos-http-api are updated. Older libraries might not handle newer Node.js behaviors correctly. Use a custom HTTP agent to override default keep-alive behavior globally for node-sonos-http-api. const agent = new http.Agent({ keepAlive: false }); Does this help in any respect? |
@virgin09 It's mostly a repetition of what I stated and the potential remedies I was thinking of 😄. But I need some reproducable error so I can validate a fix. I'm trying to run it using v20.11.0 but I'm not seeing the same behavior. I also run MacOS here, which might affect things. Could you please state exact 20 version you are running, and which OS/Arch (like, Linux amd64 or arm64 or if it's windows). |
Thanks for your quick response. I am using node.js 20.18.1. The os is PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" If you need further information, let me know. Also, if you want me to test anything, I am willing to help. |
Here further details of my system when its not working: PlatformOperating system:linux And here are the details of the system when the API works perfectly: PlatformOperating system:linux I hope that helps you to validate a fix. And, as mentioned before, I am willing to support. If you want me to conduct some tests, let me know. |
Anyone have any news here? I'd love to bring this Sonos http api back to a stable working state. Today the first TTS announcement at 0805 worked, second TTS at 0836 was not spoken, however the mp3 file was generated properly (and can be found in \node-sonos-http-api\static\tts ). I'm running Node 22.12.0. |
@jishi good Morning Jishi, have you been able to work on the fix? I would very much appreciate your help! Kind regards from Germany. |
Hi, I have been trying to reproduce it but I'm not seeing the same errors,
although I'm getting unexpected timeouts which I think stems from the same
changes in node.js but I haven't had time to work on a fix yet.
|
I was testing my install today. I ran this command (ip hidden): Sonos http api responded with: However, the Sonos radio channel started playing around 2 seconds after the error message occurred. |
Thanks for your kind reply. There is no rush as my systems still runs perfectly under 18. and also I don’t want to push. But still I would love to update node.js to the latest version. That is why I would appreciate if you will find some time to update and work on the fix in the near future. If I can be of any help don’t hesitate to get in touch. Greetings from Germany. |
Happy New year @jishi. I wanted to ask wether or not you found some time to deal with this issue? Your Sonos api is so much worth for me and others and it would be sad if one cannot use it anymore under newer versions of node.js. It seems there is no other person than yourself who can fix the problem. Hope for your help, Bernd |
Up to node.js 18 the API worked wonderful. I am many using it with automated announcements from a JavaScript.
I am very sure that there is a connection between the malfunction of the API and node.js 20. As I am running my installation under Orcacle VirtualBox I can switch back and forth between the node.js versions 18 and 20.
Since node.js 20 I am receiving error messages „error=socket hang up“. They some repeatingly in a random manner. I was unable to identify the reason and source. I have been running many test,
announcements/ text too long?,
wrong strings?,
too fast after one another announcement?
Alle the tests ended nowhere. Randomly the announcements go thru sometimes after the third time, sometimes the first. But many times comes the socket hand up.
I also tried to start from a browser like chrome. As a result the browser notifies me „no connection to the server“. And - despite - it would play the announcement. Then, I get the same error message and it would not play. And the, sometimes, after the second call it works.
I am kind of desperate.
Has anyone experienced the same issue?
How can I solve this problem?
What can I test?
The text was updated successfully, but these errors were encountered: