-
Notifications
You must be signed in to change notification settings - Fork 460
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. |
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: