Closed ashenshugarRET closed 2 years ago
Thank you!
Hi @ashenshugarRET The BBC services cause a crash when running on a clean install. To reproduce:
Hello @jsiegenthaler
My involvement was to update the readme file, the BBC Sounds service was created by @tomslominski, can you help with the issue raised?
@ashenshugarRET Thanks! I couldn't remember who wrote the service code for the BBC stuff. @tomslominski I'm happy to help you as I am trying to document the http sonos api for new users... and thus am currently doing default installs. Plus, I like the BBC...
No probs, I can definitely check it out! What OS and node version are you using, and what station are you trying to play?
No problems, can you confirm that the current repository runs if the BBC service file is deleted and could you post the crash message?
@tomslominski , @ashenshugarRET I'll post it tonight when I get home from work
@tomslominski , @ashenshugarRET
Running on Raspberry Pi 4B OS: Raspbian GNU/Linux Buster (10) Node.js Version | v16.14.2 Npm Version | v8.5.5 Pi IP address 192.168.0.100
Steps to reproduce:
# remove all old installs (or rename if you want to keep the old instance)
cd $home
sudo rm node-sonos-http-api -r
# do a new clone and install
sudo git clone https://github.com/jsiegenthaler/node-sonos-http-api.git
cd node-sonos-http-api
sudo npm install --production
sudo npm start
observe that http sonos api has started confirm the api has started: http://192.168.0.100:5005/
Try to open the bbc service: http://192.168.0.100:5005/kitchen%20sonos/bbcsounds/play/bbc_radio_one
observe the crash:
2022-03-28T17:30:10.745Z INFO Could not find file /home/pi/node-sonos-http-api/settings.json
2022-03-28T17:30:10.972Z INFO Presets loaded: {
example: {
players: [
{ roomName: 'Bathroom', volume: 10 },
{ roomName: 'Kitchen', volume: 10 },
{ roomName: 'Office', volume: 10 },
{ roomName: 'Bedroom', volume: 10 },
{ roomName: 'TV Room', volume: 15 }
],
playMode: { shuffle: true, repeat: 'all', crossfade: false },
pauseOthers: false
}
}
2022-03-28T17:30:11.982Z INFO http server listening on 0.0.0.0 port 5005
2022-03-28T17:32:01.967Z ERROR
Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control
at Object.invoke (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:99:10)
at Player.setAVTransport (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:727:15)
at Object.bbcSounds [as bbcsounds] (/home/pi/node-sonos-http-api/lib/actions/bbcSounds.js:28:31)
at handleAction (/home/pi/node-sonos-http-api/lib/sonos-http-api.js:117:35)
at HttpAPI.requestHandler (/home/pi/node-sonos-http-api/lib/sonos-http-api.js:94:21)
at /home/pi/node-sonos-http-api/server.js:50:13
at Server.finish (/home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:111:13)
at finish (/home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:170:14)
at /home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:144:17
at FSReqCallback.oncomplete (node:fs:198:21)
(node:4994) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
the browser displays:
{"status":"error","error":"Got status 500 when invoking /MediaRenderer/AVTransport/Control","stack":"Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control\n at Object.invoke (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:99:10)\n at Player.setAVTransport (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:727:15)\n at Object.bbcSounds [as bbcsounds] (/home/pi/node-sonos-http-api/lib/actions/bbcSounds.js:28:31)\n at handleAction (/home/pi/node-sonos-http-api/lib/sonos-http-api.js:117:35)\n at HttpAPI.requestHandler (/home/pi/node-sonos-http-api/lib/sonos-http-api.js:94:21)\n at /home/pi/node-sonos-http-api/server.js:50:13\n at Server.finish (/home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:111:13)\n at finish (/home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:170:14)\n at /home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:144:17\n at FSReqCallback.oncomplete (node:fs:198:21)"}
note that the above steps are exactly what a new user would do.
What Sonos speaker do you have, and are you logged into BBC Sounds in the main Sonos app? I tested this against your node version, and it works, and in any case I think it's an issue with the speaker refusing/not understanding what it's been asked to play.
I have a number of Ikea Symfonisk and some Sonos One SL. All of them are Sonos S2 capable speakers. They work well in Sonos, and they work well with TTS in the Sonos Http Api. I am not logged into BBC Sounds in the Sonos App. I am following the instructions in the Sonos Http Api about how to play the BBC stations. The instructions say nothing whatsoever about logging in to BBC Sounds.
The instructions say (quoted from the Readme.md):
BBC Sounds You can specify a BBC station and the station will be played or set depending on the command used.
To play immediately: /RoomName/bbcsounds/play/{stream code}
To set the station without playing: /RoomName/bbcsounds/set/{stream code}
Last night I upgraded all dependencies and today I tried again. Same result: http://192.168.0.100:5005/kitchen%20sonos/bbcsounds/play/bbc_radio_one {"status":"error","error":"Got status 500 when invoking /MediaRenderer/AVTransport/Control","stack":"Error: Got status 500 when invoking /MediaRenderer/AVTransport/Control\n at Object.invoke (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/helpers/soap.js:99:10)\n at Player.setAVTransport (/home/pi/node-sonos-http-api/node_modules/sonos-discovery/lib/models/Player.js:727:15)\n at Object.bbcSounds [as bbcsounds] (/home/pi/node-sonos-http-api/lib/actions/bbcSounds.js:28:31)\n at handleAction (/home/pi/node-sonos-http-api/lib/sonos-http-api.js:117:35)\n at HttpAPI.requestHandler (/home/pi/node-sonos-http-api/lib/sonos-http-api.js:94:21)\n at /home/pi/node-sonos-http-api/server.js:50:13\n at Server.finish (/home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:111:13)\n at finish (/home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:170:14)\n at /home/pi/node-sonos-http-api/node_modules/node-static/lib/node-static.js:144:17\n at FSReqCallback.oncomplete (node:fs:198:21)"}
This is an unhandled error. Regardless of why the error occurs, it should be handled better so that the Sonos Http Api just shows a better response such as "http 500 unauthorized" or whatever.
Can you try logging into BBC Sounds via the Sonos app, and we'll see if that fixes it? If that's the case @ashenshugarRET can add a note to the README to reflect this.
I did try to catch the error, but it seems the error is sent back to the client before I can do anything with it, unfortunately.
I can certainly look to addinstructions to point people in the direction of the instructions on the Sonos site on adding services (https://support.sonos.com/s/article/2757?language=en_US) and to make it clear this is needed before node-sonos-http-api will work for each particular one.
Does BBC Sounds need a logon? Ahh... I just researched BBC Sounds: https://www.bbc.co.uk/sounds/help/questions/listening-on-a-smart-speaker/sonos
So it has become clear that the following text needs to be added to the Readme.md to make it clear to the reader what the prerequisites for BBC Sounds are:
To use BBC Sounds
1. You must setup a BBC Sounds account. See https://www.bbc.co.uk/sounds/help/questions/listening-on-a-smart-speaker/sonos
2. As of 2022, the service is limited by the BBC to the UK only.
As I do not live in the UK, there's obviously no way I can use this BBC Sounds service.
So please just update the Readme.md so that other Sonos Http Api users do not get misled and confused like I was.
I've updated the README.md and created a pull request @jishi please can you approve it.
Thanks both!
Adding in instructions for the BBC Sounds service created by tomslominski