philippe44 / AirConnect

Use AirPlay to stream to UPnP/Sonos & Chromecast devices
Other
3.52k stars 218 forks source link

Post-Sonos speaker update, AirConnect no longer works #458

Closed bulbathor closed 1 year ago

bulbathor commented 1 year ago

Been using AirConnect for several years on a Raspberry Pi without issues. Yesterday, after the Sonos app updated my speakers, AirConnect no longer works. My devices can see and briefly connect to the speakers, but no audio is played and it disconnects after about 10 seconds. Not sure if the Sonos update is a coincidence or if it broke something? Nothing else has changed on the network--same devices (tried with iPhone, iPad, Mac), same router, same Raspberry Pi (no firewall). I ended up formatting and starting over, but still have the same issue. When I run the debug, here's what I get when I try to connect:

airupnp log [15:00:15.950588] main:1360 Starting airupnp version: v1.0.16 (Mar 22 2023 @ 17:46:08) [15:00:15.951072] main:1367 no config file, using defaults [15:00:16.005510] Start:1083 Binding to iface eth0@192.168.1.20:0 [15:00:16.573221] AddMRDevice:1009 [0x72a0a008]: adding renderer (Living Room) with mac BBBBC2266E3E [15:00:16.592486] MasterHandler:640 [0x72a0a008]: subscribe success [15:00:16.612120] ProcessEvent:445 [0x72a0a008]: UPnP Volume local change 31:31 (master) [15:00:16.620345] AddMRDevice:1009 [0x72a0c350]: adding renderer (Bedroom) with mac BBBB4E8395CA [15:00:16.632913] MasterHandler:640 [0x72a0c350]: subscribe success [15:00:16.647247] ProcessEvent:445 [0x72a0c350]: UPnP Volume local change 33:33 (master) [15:00:16.680712] AddMRDevice:1009 [0x72a0e698]: adding renderer (Kitchen) with mac BBBB568395CA [15:00:16.703084] MasterHandler:640 [0x72a0e698]: subscribe success [15:00:16.726928] ProcessEvent:445 [0x72a0e698]: UPnP Volume local change 11:11 (master) [15:00:16.729261] AddMRDevice:1009 [0x72a109e0]: adding renderer (Office) with mac BBBBCE9C07FD [15:00:16.745976] MasterHandler:640 [0x72a109e0]: subscribe success [15:00:16.760405] ProcessEvent:445 [0x72a109e0]: UPnP Volume local change 23:23 (master) [15:00:32.231732] rtsp_thread:322 got RTSP connection 16 [15:00:32.305744] handle_rtsp:369 [0x70e0e5f0]: challenge dhCk+KsJsaEH7eoHXm5LZg== [15:00:32.344704] handle_rtsp:363 [0x70e0e5f0]: received ANNOUNCE [15:00:32.401166] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 4 [15:00:32.405946] handle_rtsp:363 [0x70e0e5f0]: received SETUP [15:00:32.415134] raopst_init:378 [0x7030e170]: UDP port-0 57755 [15:00:32.415418] raopst_init:378 [0x7030e170]: UDP port-1 53019 [15:00:32.415541] raopst_init:378 [0x7030e170]: UDP port-2 41863 [15:00:32.415692] raopst_init:396 [0x7030e170]: HTTP listening port 60871 [15:00:32.416505] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Transport: RTP/AVP/UDP;unicast;mode=record;control_port=53019;timing_port=41863;server_port=57755 Session: DEADBEEF Audio-Jack-Status: connected; type=analog CSeq: 5 [15:00:32.421230] handle_rtsp:363 [0x70e0e5f0]: received RECORD [15:00:32.421360] raopst_record:499 [0x7030e170]: record 0 0 [15:00:32.421427] HandleRAOP:288 [0x72a0c350]: Stream [15:00:32.421728] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 6 [15:00:32.426264] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:32.426490] handle_rtsp:528 [0x70e0e5f0]: SET PARAMETER volume -20.000000 [15:00:32.426611] CtrlSetVolume:232 [0x72a0c350]: uPNP volume 33 (cookie (nil)) [15:00:32.427162] HandleRAOP:365 [0x72a0c350]: Volume[0..100] 33:33 [15:00:32.427378] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 7 [15:00:32.431242] rtp_thread_func:733 [0x7030e170]: 1st sync packet received [15:00:32.457480] flac_init:195 [0x7030e170]: Using FLAC-0 (0x70d012b0) [15:00:32.458019] buffer_put_packet:617 [0x7030e170]: fill [level:1] [W:33312 R:33312] [15:00:32.748060] handle_rtsp:363 [0x70e0e5f0]: received FLUSH [15:00:32.748496] raopst_flush:483 [0x7030e170]: flush 33312 1947071043 [15:00:32.748625] HandleRAOP:302 [0x72a0c350]: Flush [15:00:32.748704] AVTStop:204 [0x72a0c350]: uPNP stop (cookie 0x1) [15:00:32.749162] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 8 [15:00:32.749511] flac_init:195 [0x7030e170]: Using FLAC-0 (0x70d012b0) [15:00:33.270342] search_remote_cb:604 [0x70e0e5f0]: found ActiveRemote for 306E4E29325EF921 at 192.168.1.7:54960 [15:00:34.350800] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:34.351144] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 9 [15:00:34.355710] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:34.355931] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 10 [15:00:34.360787] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:34.360914] handle_rtsp:544 [0x70e0e5f0]: received metadata artist: M83ascp album: Fantasyasar title: Water Deepastn [15:00:34.361134] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 11 [15:00:36.543013] buffer_put_packet:617 [0x7030e170]: fill [level:503] [W:33824 R:33322] [15:00:36.632820] ActionHandler:513 [0x72a0c350]: uPNP stopped [15:00:37.399843] AVTSetURI:78 [0x72a0c350]: uPNP setURI http://192.168.1.20:60871/stream-0.flc (cookie 0x4) [15:00:37.400468] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:37.401144] AVTPlay:138 [0x72a0c350]: uPNP play (cookie 0x5) [15:00:37.401515] handle_rtsp:544 [0x70e0e5f0]: received metadata artist: M83ascp album: Fantasyasar title: Water Deepcaps [15:00:37.401743] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 14 [15:00:37.407424] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:37.407777] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 15 [15:00:37.444437] http_thread_func:1055 [0x7030e170]: got HTTP connection 27 (silent frames 0) [15:00:37.446700] handle_http:1230 [0x7030e170]: received GET HTTP/1.1 CONNECTION: close Host: 192.168.1.20:60871 ACCEPT: */* USER-AGENT: Linux UPnP/1.0 Sonos/72.2-39150 (ZPS12) X-Sonos-SWGen: 2 X-Sonos-Firmware: 72.2-39150 X-Sonos-Muse-Api: 1.33.2 X-Sonos-Id-Hash: gMtjDf33DYOHwzVOyM4mLk6PsdoIKC1i+0INzuG+D8I= [15:00:37.447810] handle_http:1275 [0x7030e170]: responding: HTTP/1.0 200 OK Server: HairTunes Content-Type: audio/flac Connection: close [15:00:37.449083] _buffer_get_frame:954 [0x7030e170]: drain [level:614 gap:-3144] [W:33936 R:33322] [R:0 S:0 F:0] [15:00:37.493659] _buffer_get_frame:954 [0x7030e170]: drain [level:108 gap:898] [W:33942 R:33834] [R:0 S:0 F:0] [15:00:38.453250] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:38.453446] handle_rtsp:544 [0x70e0e5f0]: received metadata artist: M83ascp album: Fantasyasar title: Water Deepcaps [15:00:38.453770] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 16 [15:00:38.459559] handle_rtsp:363 [0x70e0e5f0]: received SET_PARAMETER [15:00:38.460592] handle_rtsp:562 [0x70e0e5f0]: responding: RTSP/1.0 200 OK Audio-Jack-Status: connected; type=analog CSeq: 17 [15:00:40.630618] buffer_put_packet:617 [0x7030e170]: fill [level:1] [W:34336 R:34336] [15:00:40.711655] _buffer_get_frame:954 [0x7030e170]: drain [level:0 gap:1765] [W:34346 R:34346] [R:0 S:0 F:0] [15:00:42.134388] ActionHandler:508 [0x72a0c350]: uPNP transition [15:00:44.740895] buffer_put_packet:617 [0x7030e170]: fill [level:7] [W:34848 R:34842] [15:00:44.800737] _buffer_get_frame:954 [0x7030e170]: drain [level:0 gap:1763] [W:34858 R:34858] [R:0 S:0 F:0] [15:00:48.803730] buffer_put_packet:617 [0x7030e170]: fill [level:1] [W:35360 R:35360] [15:00:48.888687] _buffer_get_frame:954 [0x7030e170]: drain [level:0 gap:1761] [W:35370 R:35370] [R:0 S:0 F:0] [15:00:49.038422] http_read_line:775 fd: 27 read error: Connection reset by peer [15:00:49.038662] http_parse_simple:698 cannot read method [15:00:49.038825] http_thread_func:1074 HTTP close 27 [15:00:49.038964] http_thread_func:1055 [0x7030e170]: got HTTP connection 27 (silent frames 0) [15:00:49.041548] handle_http:1230 [0x7030e170]: received HEAD HTTP/1.1 CONNECTION: close Host: 192.168.1.20:60871 USER-AGENT: Linux UPnP/1.0 Sonos/72.2-39150 (ZPS12) X-Sonos-SWGen: 2 X-Sonos-Firmware: 72.2-39150 X-Sonos-Muse-Api: 1.33.2 X-Sonos-Id-Hash: gMtjDf33DYOHwzVOyM4mLk6PsdoIKC1i+0INzuG+D8I= [15:00:49.041839] handle_http:1275 [0x7030e170]: responding: HTTP/1.0 200 OK Server: HairTunes Content-Type: audio/flac Connection: close [15:00:49.042169] http_thread_func:1074 HTTP close 27 [15:00:49.130100] ActionHandler:531 Error in action callback -- -204 (cookie 0x12) [15:00:49.583810] UpdateThread:716 [0x72a0c350]: renderer bye-bye: Bedroom+ [15:00:49.593354] http_thread_func:1211 [0x7030e170]: terminating [15:00:49.594374] rtp_thread_func:822 [0x7030e170]: terminating

If it's at all useful, both the older Play:1 speakers that aren't working are on Sonos OS: S2, Version 15.2 (build 72239150)

Any help would be appreciated!

pwt commented 1 year ago

Hi @philippe44: Unfortunately, I'm seeing what looks like the same issue with Sonos S2 (15.2): the 15.2 update happened overnight for me, and airupnp was working fine yesterday.

I'm currently running airupnp version: v1.0.14.

Sonos S1 (11.8) appears still to be working fine with airupnp.

Let me know if I can assist with any diagnostics.

philippe44 commented 1 year ago

Can you try using mp3 or wav for the format of audio sent to the Sonos? You can also try to use chunked mode for http. But in general, this is what I was afraid of, that at some point, Sonos would do an update that would sc..w up the UPnP compatibility, because they don't care

pwt commented 1 year ago

But in general, this is what I was afraid of, that at some point, Sonos would do an update that would sc..w up the UPnP compatibility, because they don't care

Yep, me too. One day I'm sure they're going to break an entire ecosystem of open source usefulness.

It's possibly something minor in this case, though. My play_file action in SoCo-CLI is still working OK, and that operates by setting up a local HTTP server to serve an audio file and instructing Sonos to play its URI, which is not dissimilar to the Sonos end of AirConnect.

bulbathor commented 1 year ago

Chunked mode didn't help, sadly. Weirdly, regardless of what audio format I'm sending, it shows audio/flac for the content type. Tried an MP3 and WAV, in Quicktime, Apple Music, and on a system-wide level.

update to add: experimented and downgraded one of the speakers to S1 and it's working again, so to me that suggests something went sideways in the update.

philippe44 commented 1 year ago

No, I mean it is an option on AirConnect command line or in the config file to tell it which codec it should use to re-encode the audio

philippe44 commented 1 year ago

But in general, this is what I was afraid of, that at some point, Sonos would do an update that would sc..w up the UPnP compatibility, because they don't care

Yep, me too. One day I'm sure they're going to break an entire ecosystem of open source usefulness.

It's possibly something minor in this case, though. My play_file action in SoCo-CLI is still working OK, and that operates by setting up a local HTTP server to serve an audio file and instructing Sonos to play its URI, which is not dissimilar to the Sonos end of AirConnect.

What I'm afraid of is that they insist on getting the size of the encoded file (content-length), which of course I don't know and is not an HTTP mandatory parameter. But that would explain why regular webserver in SoCo-CLI works. Best way to check is to use WAV

bulbathor commented 1 year ago

No, I mean it is an option on AirConnect command line or in the config file to tell it which codec it should use to re-encode the audio

Oh I see, apologies for the misunderstanding. This fix works! Thank you!

edit to add: tested this last night and this morning for a couple hours. WAV works just fine on my two Play:1's, both on S2.

Spy-1 commented 1 year ago

Strangely, in my system, the Play 3 (S2) do work, but the Play 1 (s2). do not work.

pwt commented 1 year ago

Best way to check is to use WAV

Thanks. Initial testing suggests that it does work with WAV.

I'm testing with Play:1 speakers, BTW. These are the only non-AirPlay devices I have running on S2.

Spy-1 commented 1 year ago

MP3 converted to WAV is not working for me on my Play:1

philippe44 commented 1 year ago

Can you describe what you do exactly?

Spy-1 commented 1 year ago

I converted a mp3 to wav.

philippe44 commented 1 year ago

I was afraid you did :-)

No you must change the parameter of AirConnect so that it sends WAV to your Sonos player. Look at the README, it explains how to change the format produced by AirConnect

Spy-1 commented 1 year ago

OK! So this is really new for me. I´m running airconnect in a docker Container. I am able to access via putty /volume1/airconnect but there are only one File -airconnect.conf and one directory -Log. if i create a file named config.xlm witch and codec wav in this directory the changes will not have any effect.

philippe44 commented 1 year ago

Best way to check is to use WAV

Thanks. Initial testing suggests that it does work with WAV.

I'm testing with Play:1 speakers, BTW. These are the only non-AirPlay devices I have running on S2.

It really seems that Sonos now refuses to handle FLAC files without knowing the size of the file. It's a shame and definitively a non-compliance to HTTP

philippe44 commented 1 year ago

OK! So this is really new for me. I´m running airconnect in a docker Container. I am able to access via putty /volume1/airconnect but there are only one File -airconnect.conf and one directory -Log. if i create a file named config.xlm witch and codec wav in this directory the changes will not have any effect.

You can use -c wav on the command line and don't have to create a config file

philippe44 commented 1 year ago

BTW, can one of you try and http_length in the config file of say 2000000000 and use flac to see if it works?

Diacius commented 1 year ago

(I am also affected by this) How can I do that, do I just do -g 0 and then a number or does it have to be done in config? EDIT: never mind I found the details in the readme

Diacius commented 1 year ago

Default format (flac) does not appear to work with -g 0 however if I use -c wav to encode to wav the audio plays fine! edit: mp3 also works although it adds a lot of delay

philippe44 commented 1 year ago

I have no idea what Sonos did. Is this to their flac decoder or to the http... My flac decoder is the official one, maybe one version below the latest and I use the "streamable" subformat which is supposed to be the most compatible one.

Diacius commented 1 year ago

I have no idea what Sonos did. Is this to their flac decoder or to the http... My flac decoder is the official one, maybe one version below the latest and I use the "streamable" subformat which is supposed to be the most compatible one.

I suspect that they changed their flac decoder and the new one needs the file size to work, or the change is completely unintentional and is just a result of something else.

Spy-1 commented 1 year ago

next strange thing for me: -c wav is working only on iPhone, iPad with both speakerts play:1 and play:3. With iTunes for Windows i can´t stream to the play:1, but play:3 works ???

philippe44 commented 1 year ago

I don't think it's related to wav. These are two very separated items. Are you 1000000% sure that this exact combination of iTunes and Sonos worked before? Like absolutely sure?

Spy-1 commented 1 year ago

Sorry for this. Itˋs working now. A restart of airconnect did it.

chucklebrother commented 1 year ago

BTW, can one of you try and http_length in the config file of say 2000000000 and use flac to see if it works?

I think this is the same as -g 0 on the comand line:

Use -g -3|-1|0| to tweak http transfer mode where -3 = chunked, -1 = no content-length and 0 = fixed (dummy) length (see "HTTP content-length" below)"

Unfortunately this did not help, unless there is something else I'm missing about specifyng an arbtraty dumy length via the config file?

In any case, use WAV format instead of FLAC does fix the issue. Thanks for the advice/workaround.

This is with a Sonos PLAY:1 using Airconnect v1.0.17 (Apr 2 2023 @ 12:01:07)

wickens commented 1 year ago

I had the same issue, after finding this thread,I changed <codec>flu</codec> to <codec>wav</codec> in the config file, and it started working. My setup: 2 Sonos 1 (from 2017) setup as a stereo pair. Using Apple Music on Mac/iPhone.

eizedev commented 1 year ago

For me with Sonos 15.3 and airupnp 1.1.0 now everything works again (Sonos Play 1) with the original Flac codec. Can you please also test it?

Spy-1 commented 1 year ago

It´s working for me too with flac codec!

philippe44 commented 1 year ago

I'll close this one then

Spy-1 commented 1 year ago

Now, with latest Sonos System Update flac does not work for me with my Play3 anymore.

philippe44 commented 1 year ago

Looks like great SW quality control on their side

Diacius commented 1 year ago

it never started working for me!

stephenjharrington commented 1 year ago

Changing my config back (as per previous workaround) to:-

<codec>wav</codec>

gets it going again for me...

Groundhog Day?

:-)

Spy-1 commented 1 year ago

The workaround is working for me too but only with my play1. My play3 are not discovered.

philippe44 commented 1 year ago

Discovery and audio format for playback are really not correlated. Are you sure it was discovered, it is not anymore and nothing in your network has changed?

Spy-1 commented 1 year ago

No changes. It was working before latest sonosupdate. When I generate the config.xml only the play1 are found.