SOLVED! - Cause of Alexa->-Plex->Sonos problems

Server Version#: 1.18.4.2171

TLDR: After an MP3 has been “analysed” then the additional loudness information held in Plex library is breaking the Direct Play http file transfer that occurs in response to a GET request issued by Alexa running on a Sonos device

I have been battling since Christmas with trying to integrate my Sonos One Gen2 with Plex and have read many posts with similar problems. - but nothing helped.

My usual Plex server is running on Xpenology and I couldn’t upgrade until I update Xpenology
So I downloaded the latest Windows 10 Plex Media server and installed on my desktop PC
I created a small test library and at first I had the following behaviour
“Alexa ask Plex to play xyz” worked on an Amazon Echo
The Sonos App could play from Plex
“Alexa ask Plex to play xyz” failed on the Sonos One
I then added some more music to the library and was surprised when it started playing OK
I then wasted some time trying to work out whether it was CDs ripped that worked or LPs recorded via Audacity etc but couldn’t find any pattern
I did see that 96K FLac files that needed to be transcoded worked OK
I started collecting Plex server logs where I started Plex, waited 1 minute and then tried a working or non working file (as discussed in my reply to another post)
I then installed Wireshark (which can capture all type of packet on the network) and then saw a clear difference

What I see if that for a working file this is a typical exchange:

GET /library/parts/8000/1571488467/file.mp3?protocol=http&hasMDE=1&session=82604d4d-114e-4e9e-aca9-55fcb529e15c&directPlay=1&mediaIndex=0&partIndex=0&offset=0&includeLoudnessTag=1&X-Plex-Token=XXXXXXXX&X-Plex-Client-Profile-Name=Generic&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%2Cmp4%2Caac%2Cwav%2Cogg%26audioCodec%3Dmp3%2Caac%2Cpcm%2Cvorbis%29%2Badd-limitation%28scope%3DmusicCodec%26scopeName%3Daac%26type%3DupperBound%26name%3Daudio.bitrate%26value%3D350%29%2Badd-limitation%28scope%3DmusicCodec%26scopeName%3Dmp3%26type%3DupperBound%26name%3Daudio.bitrate%26value%3D350%29%2Badd-limitation%28scope%3DmusicCodec%26scopeName%3Dwav%26type%3DupperBound%26name%3Daudio.samplingRate%26value%3D48000%29%2Badd-transcode-target%28type%3DmusicProfile%26context%3Dstreaming%26protocol%3Dhttp%26container%3Dmp3%26audioCodec%3Dmp3%29&X-Plex-Session-Identifier=3f0ad5dfa2a7b02e9249ba99e5c092719173034a&X-Plex-Chunked=1&X-Plex-Product=Plex%20for%20Alexa&X-Plex-Version=3.0.0&X-Plex-Device=Alexa&X-Plex-Device-Name=Alexa&X-Plex-Client-Identifier=3f0ad5dfa2a7b02e9249ba99e5c092719173034a&X-Plex-Features=external-media&Accept=application%2Fjson HTTP/1.1
CONNECTION: close
Host: 192.168.0.1:32400
ACCEPT: /
USER-AGENT: Linux UPnP/1.0 Sonos/54.2-72031 (ZPS18)

HTTP/1.1 200 OK
ETag: “65f50293a7d1ec5035613630a995b7b3b3a6991d”
Last-Modified: Thu, 02 Jan 2020 12:31:18 GMT
Accept-Ranges: bytes
Connection: close
Content-Length: 7326567
Content-Type: audio/mpeg
X-Plex-Protocol: 1.0
Date: Thu, 02 Jan 2020 12:31:38 GMT

…d…Xing…!>.o…
(rest of MP3 file )
(The 7.5MB file is transferred as a series of TCP packets with regular ACKs by the Sonos)

For a failed file then
GET /library/parts/7901/1572734809/file.mp3?protocol=http&hasMDE=1&session=11e15f53-7666-4cd1-a11f-1de3721746a2&directPlay=1&mediaIndex=0&partIndex=0&offset=0&includeLoudnessTag=1&X-Plex-Token=XXXXXXXXXXX&X-Plex-Client-Profile-Name=Generic&X-Plex-Client-Profile-Extra=add-direct-play-profile%28type%3DmusicProfile%26container%3Dmp3%2Cmp4%2Caac%2Cwav%2Cogg%26audioCodec%3Dmp3%2Caac%2Cpcm%2Cvorbis%29%2Badd-limitation%28scope%3DmusicCodec%26scopeName%3Daac%26type%3DupperBound%26name%3Daudio.bitrate%26value%3D350%29%2Badd-limitation%28scope%3DmusicCodec%26scopeName%3Dmp3%26type%3DupperBound%26name%3Daudio.bitrate%26value%3D350%29%2Badd-limitation%28scope%3DmusicCodec%26scopeName%3Dwav%26type%3DupperBound%26name%3Daudio.samplingRate%26value%3D48000%29%2Badd-transcode-target%28type%3DmusicProfile%26context%3Dstreaming%26protocol%3Dhttp%26container%3Dmp3%26audioCodec%3Dmp3%29&X-Plex-Session-Identifier=3f0ad5dfa2a7b02e9249ba99e5c092719173034a&X-Plex-Chunked=1&X-Plex-Product=Plex%20for%20Alexa&X-Plex-Version=3.0.0&X-Plex-Device=Alexa&X-Plex-Device-Name=Alexa&X-Plex-Client-Identifier=3f0ad5dfa2a7b02e9249ba99e5c092719173034a&X-Plex-Features=external-media&Accept=application%2Fjson HTTP/1.1
CONNECTION: close
Host: 192.168.0.1:32400
ACCEPT: /
USER-AGENT: Linux UPnP/1.0 Sonos/54.2-72031 (ZPS18)

HTTP/1.1 200 OK
ETag: “035adb92ed2b42537e2770186ac60bd0a9ecfad0”
Last-Modified: Tue, 31 Dec 2019 08:33:10 GMT
Accept-Ranges: bytes
Connection: close
Content-Length: 7323339
Content-Type:
X-Plex-Protocol: 1.0
Date: Wed, 01 Jan 2020 18:37:37 GMT

ID3…TXXX…replaygain_track_gain.-2.37 dBTXXX…"…replaygain_track_peak.0.750916 dBRVA2…track…C…;TXXX…replaygain_album_gain.-1.21 dBTXXX…"…replaygain_album_peak.0.805328 dBRVA2…album…)TXXX…k…mixramp_start.-51.00 0.00;-34.79 0.40;-11.00 0.50;-8.76 0.70;-5.66 3.10;-2.72 7.50;1.03 67.90;3.14 157.10;TXXX…*…mixramp_end.-51.00 0.18;-39.44 2.58;-29.76 7.58;-23.01 8.68;-20.63 9.58;-17.07 11.48;-14.97 13.28;-11.97 15.28;-8.90 17.38;-5.97 22.78;-2.64 25.58;0.95 29.28;3.12 30.18;TXXX…mixramp_ref.89.00…

and then the start of the MP3 file but the transfer would get aborted early on

So the two difference are that the Content Type changes from audio/mpeg to blank
There is also the additional loudness information

I was able to force a working file to non working by executing an analysis on the library and restarting plex (Get Info on the file then shows the additional loudness data)
I could then recover by removing the content from the library and then adding it back again
I’ve set the server to Never analyse the library

I’ve also analysed the exchange for the Sonos App and while it looks like the failed case (no content type and the loudness information" the GET instruction is a lot shorter

Request by Sonos App (Works)
GET /library/parts/7901/1572734809/file.mp3?X-Plex-Session-Identifier=48-A6-B8-82-4A-60%3A8&includeLoudnessTag=1&X-Plex-Product=Plex%20for%20Sonos&X-Plex-Version=3.0.0&X-Plex-Device=Sonos&X-Plex-Client-Identifier=sonos-28a974da-6d9b-474a-bcd9-b3829f8c25e1&X-Plex-Token=XXXXXXXXXX&X-Plex-Platform=Sonos&Accept=application%2Fjson HTTP/1.1
CONNECTION: close
Host: 192.168.0.1:32400
ACCEPT: /
USER-AGENT: Linux UPnP/1.0 Sonos/54.2-72031 (ZPS18)

HTTP/1.1 200 OK
ETag: “035adb92ed2b42537e2770186ac60bd0a9ecfad0”
Last-Modified: Tue, 31 Dec 2019 08:33:10 GMT
Accept-Ranges: bytes
Connection: close
Content-Length: 7323339
Content-Type:
X-Plex-Protocol: 1.0
Date: Thu, 02 Jan 2020 10:29:50 GMT

ID3…TXXX…replaygain_track_gain.-2.37 dBTXXX…"…replaygain_track_peak.0.750916 dBRVA2…track…C…;TXXX…replaygain_album_gain.-1.21 dBTXXX…"…replaygain_album_peak.0.805328 dBRVA2…album…)TXXX…k…mixramp_start.-51.00 0.00;-34.79 0.40;-11.00 0.50;-8.76 0.70;-5.66 3.10;-2.72 7.50;1.03 67.90;3.14 157.10;TXXX…*…mixramp_end.-51.00 0.18;-39.44 2.58;-29.76 7.58;-23.01 8.68;-20.63 9.58;-17.07 11.48;-14.97 13.28;-11.97 15.28;-8.90 17.38;-5.97 22.78;-2.64 25.58;0.95 29.28;3.12 30

So I can now access all my (test) library by voice command and I also understand why files stopped working overnight (by default the server carries out a depp analysis of the library after 02:00)

It doesn’t explain why the casting from Plex app still fails but hopefully this might give the developers some idea.

I would be interested to hear if any other Sonos users see the same behaviour with analysed and not analysed files

2 Likes

So this allows you to play Plex content via Alexa voice commands to Sonos? Is it any Sonos speaker or just the Sonos One or other Alexa-enabled Sonos speaker?

I ask because I have several Sonos speakers but none are Alexa enabled. I would LOVE to be able to use Alexa to play my Plex music on my Sonos speakers!

So far I only have it working on the Sonos One with Alexa built in. (and these are my only Sonos devices)
The only idea I have is that this page describes one Plex voice command to select player e.g. “Ask Plex to change my player to Living Room TV”.
However my casting to Sonos from Plex app or Browser is still not working and I think this would be a necessary first step before even hoping to get a voice command to succeed

I have exactly the same problem - Sonos One, Plex, etc. with all the latest updates.
I tried switching off analysis, but it did not clear the problem.
Thanks for all your efforts, let’s hope someone in Plex/Sonos/Alexa development will now be able to provide a solid solution.

1 Like

Just checking: when you say that you switched off the analysis - did you add new tracks after switching it off as disabling the analysis just stops it from analysing new material?

I have just deleted and restored a CD and voice control worked. So disabling analysis seems to do the trick. I have 170 albums so deleting and restoring all of them will take a while. Do you have any recommendations as to how this may be done without deleting all the CDs?

Thanks again for your investigations.

Adding to my previous comment, I have re-scanned my music folder and found that Alexa voice control of Plex now works for all the CDs I have tried , so far. So, maybe all that is needed is to re-scan a CD rather than to delete and then add it back.
I have also restarted my PC to confirm that this solution still works. However, I have not restarted my NAS drive (on permanently) which stores my music and the Plex server.
Finally, I also updated (after receiving prompts) my Plex server and Plex Player - which were running the previous versions, not old versions.

If the situation changes, I will report back.

Last night I closed down my PC, but not the NAS (WD PR4100). Then this morning I started Sonos One and PC, but Alexa would not control Plex. However, after waking up Plex Server using my phone, Alexa was then able to control Plex without any further intervention.

So, for my system, after a long period of inactivity, it looks like the Plex Server has to be woken up by a Plex Player prior to being able to use Alexa voice control.

If the situation changes, I will report back.

I found “Alexa Open Plex” and then “select server” seemed to wake it up (even though I only had one server running)

I have re-scanned my music folder and found that Alexa voice control of Plex now works for all the CDs I have tried
That sounds far less trouble then rebuilding from scratch - good to know!

Thanks, I will try your suggestion: “Alexa Open Plex” and then “select server”.

Tried “Alexa Open Plex” again this morning after booting PC and starting Sonos One. Alexa voice control of my local music still working OK.

It looks like this problem is solved.

Yeah don’t count on it. I’m in Plex/Sonos/Alexa HELL right now. Totally does not work.

I’m with you MattScales. I’ve been hoping for something simple that just works forever. In the mean time, I have come up with something complicated that works but is not trivial to set up.

If you are brave, you can set up an AWS service the hooks to a local server to enable voice commands. It’s a bit kludgy but works for my needs. I blogged about how I did it here:

If you’re not comfortable manually configuring things, setting up AWS services, etc. then this probably won’t work for you. It works for me and I get the music I want about 80% of the time.

Good luck!

Thanks for the link, but as that’s from 2016? You’ll see that the Sonos Alexa skill is now available, has been for ages now and is definitely much more useable in 2020. Alexa definitely obeys the play music voice command, as well as pause, resume and being able to understand if you want a station from TuneIn, or from Amazon Music or Apple Music very well.

The Plex Alexa skill is terrible. I can rarely get music to play, Alexa seems to really fail when trying to access a Plex library either for songs or TV and music. I get unknown file format errors on a basic mp3 that plays just fine through the Sonos app, or the Plex app but if you ask Alexa to play a song to sonos from Plex or an episode from Plex to the tv it’s a complete fail for me 99% of the time.

So Alexa for sonos though is really pretty OK. It’s a bit glitchy on skipping tracks, but there’s probably no need for most of us to set up an AWS service any more. Just install the Sonos skill. While not perfect, it is much, much better and more reliable than the Plex Alexa skill is.

I’ve just stumbled on this thread while researching an upgrade from Alexa speakers to Sonos to improve sound quality on a multi-room setup. I’m trying to catchup on the current state of affairs but is it right that Alexa control of Plex libraries via Sonos is effectively broken?

All I want is to be able to say to a Sonos One “Alexa, ask Plex to play some music in the loft” and have the Plex Library Radio start on the pair of Sonos One speakers called “Loft” that I will setup in the Alexa app as a multi-room group.

My PMS is on an always on Win10 NUC with MP3 media stored locally. Lifetime Plex Pass.

Am I asking too much of all this expensive equipment at this point in time?

@MattScales You are correct, the Plex Alexa skill is terrible. That’s the problem. All of the music I want the listen to is on Plex. I’m not willing to pay a subscription to listen to my own music (plus I have a few tracks that are custom so a music service wouldn’t have it). I used to have all of my music on Amazon but they got rid of that service. So I found the custom solution. It’s not nearly as good as the Sonos Alexa skill except that it can play anything in your Sonos library not just what Amazon supports. It’s old but it works and until Plex/Sonos/Amazon figure out how to work together, it’s better than anything I’ve found.

I keep waiting for something better but, in the mean time, I’ve got something that works. This certainly won’t work for everybody but it works for me.

Yes what you are seeking should work. No it doesn’t do so consistently.

I end up using the Sonos app to play my
Plex content and then using Alexa to stop and start playback: but it’s erratic and Sonos are well aware (who knows if plex are aware or care) that there are a lot of issues with the Skills for Sonos and Plex on Alexa. Search tracks can’t skip on Sonos and Alexa playback issues on the Sonos forum.

Well I upgraded to Sonos One for the improved sound quality but as expected, Alexa control doesn’t work. i have to start/stop music from the Sonos app. Starting from the Plex app and casting to the Sonos also doesn’t work, just spinning wheel. At least once the music is going I can stop/skip tracks with Alexa voice control, so that’s something.

When asking Plex for music, I get the correct response from Alexa but then the following mesaages in the Sonos app. Seems like it’s so close to working…

Mod-Edit: removed screenshot with user token
Please never post this information. It’s like giving away your user credentials on a public marketplace

So do you confirm that Plex has not analyzed this file ?
i.e. if younavigate to the track in Plex and select “… Get Info” there is no loudness information?

This is controlled in the server by Settings->Library (and scroll down)

Just rechecked and “Alexa ask Plex to play …” worked first time on ,my Sonos One