Chromecast: "Could not switch to player" on any Chromecast device

Server Version#: 1.24.1.4931
Player Version#: Plexamp 3.5.0

I have successfully set up Plex to be usable both internally and external to my network, such that I can play music on Plexamp on and off of the network. However, when I attempt to use Chromecast while on my local network to connect to any of my Google Home & Chromecast devices I get the error “Could not switch to player”. The device does seem to at least do an initial handshake: for instance, my google home devices make a chime sound. But that’s followed immediately by the “could not switch to player” message.

Specifics I should note about my setup:

  • I have an external domain that is passing through Cloudflare, a local firewall, and then nginx such that incoming requests to music.mydomain.com:443 are redirected to plex’s port 32400. This setup works fine for Plexamp both remotely and locally, but somehow seems to be a problem for Chomecast and I’m not sure why.

  • Something odd about the logs below to me is that it’s trying to hit some kind of plex.direct subdomain that has my plex server’s local IP address in its URL. What is going on there?

I look at the messages below and don’t have a feel for what is actionable/what’s actually going wrong. Anyone have any experience with this?

— Logs from Plexamp during the connection failure —

Sep 04, 2021 09:06:39.908 [Javascript] INFO - Cast: State is currently Connected.
Sep 04, 2021 09:06:39.908 [Javascript] INFO - Cast: Ending existing session to [LOCAL_DEVICE ID] so we can connect to [GOOGLE HOME LIVING ROOM DEVICE ID]
Sep 04, 2021 09:06:39.919 [Javascript] INFO - Cast: Session ending.
Sep 04, 2021 09:06:39.919 [Javascript] INFO - Cast: Session ending.
Sep 04, 2021 09:06:39.938 [Javascript] INFO - Cast: Session ended null
Sep 04, 2021 09:06:39.939 [Javascript] INFO - Cast: Session ended null
Sep 04, 2021 09:06:39.940 [Javascript] INFO - Cast: Starting new session.
Sep 04, 2021 09:06:41.727 [Javascript] INFO - Cast: Session started.
Sep 04, 2021 09:06:41.727 [Javascript] INFO - Cast: Session started.
Sep 04, 2021 09:06:41.727 [Javascript] INFO - Cast: Starting channel.
Sep 04, 2021 09:06:41.730 [Javascript] INFO - Cast: Successfully connected to [GOOGLE HOME LIVING ROOM DEVICE ID].
Sep 04, 2021 09:06:41.730 [Javascript] INFO - Audio Route: Switched over to player Living Room (volume: NaN).
Sep 04, 2021 09:06:41.731 [Javascript] INFO - Cast: using https / undefinedmusic.mydomain.com / 443 for connection URI https://music.mydomain.com:443.
Sep 04, 2021 09:06:41.770 [Javascript] INFO - Cast: unknown player state.
Sep 04, 2021 09:06:41.830 [0x22ad0cc0] DEBUG - Networking: Completed request 29: (GET https://music.mydomain.com:443/security/token?type=delegation&scope=all&includeFields=thumbBlurHash&X-Plex-Device-Name=Android) with code 200 (have 86 bytes) in 91 ms.
Sep 04, 2021 09:06:41.905 [Javascript] INFO - Cast: unknown player state.
Sep 04, 2021 09:06:41.905 [Javascript] INFO - Cast: Got event for state stopped.
Sep 04, 2021 09:06:41.905 [Javascript] INFO - Audio Route: Waiting for something other than stopped, currently stopped.
Sep 04, 2021 09:06:41.913 [Javascript] INFO - Cast: unknown player state.
Sep 04, 2021 09:06:41.921 [Javascript] INFO - Cast: unknown player state.
Sep 04, 2021 09:06:43.393 [0x22ad0cc0] DEBUG - Networking: Completed request 26: (GET https://192-168-2-245.cca7e40b4b0a4a468dacf67dbdc230db.plex.direct:32400/) with code -28 (have 0 bytes) in 15003 ms.
Sep 04, 2021 09:06:43.396 [Javascript] WARNING - DEVICE: Server connection [SAME AS LINE ABOVE, had to remove because Plex won’t let me post more than 5 links as a new user] didn’t work for plex: HTTP status -28
Sep 04, 2021 09:06:44.020 [Javascript] INFO - Player: Ignoring event local paused
Sep 04, 2021 09:06:48.565 [Javascript] INFO - Sync: Error cleaning up: failed to lstat path /data/user/0/tv.plex.labs.plexamp/files/Offline because it does not exist or it is not a folder.
Sep 04, 2021 09:06:49.015 [Javascript] INFO - Player: Ignoring event local paused
Sep 04, 2021 09:06:51.923 [Javascript] INFO - Audio Route: Issued play, waited for start with success false.
Sep 04, 2021 09:06:51.923 [Javascript] INFO - Cast: Sending message ‘STOP’.
Sep 04, 2021 09:06:51.923 [Javascript] WARNING - Audio Route: Error switching player to Living Room.

Very interesting follow up info - I installed the normal plex android app instead of plexamp, and using that I was able to successfully connect with Chromecast and play music on my google home.

It’s succeeding with anything I throw at it through the normal Plex app. So what’s the difference between how Plexamp uses Chromecast and the normal Plex app? I’d prefer to use Plexamp for my music streaming.

This is a pretty “exotic” setup, so it seems most likely it’s messing with Chromecast in some way, but I’m not sure what that might be. I’m also not entirely sure why it’s passing the https://music.mydomain.com:443 domain over to the Chromecast when it can likely access over LAN.

So not sure what’s up, but almost certainly something with your rather different network setup. My guess is the Chromecast can’t access PMS via that URL for some reason.

1 Like

Thank you for giving the post a look! I really appreciate it.

Yeah, definitely a little odd admittedly, I got a little paranoid in my home server setup and may have gone a bit overboard. I was trying to keep my VMs somewhat locked down, so I have them on their own VLAN hosted on proxmox, and that’s why there’s the cloudflare->firewall->nginx access route. Nothing outside of the other VMs can access each other except through the exposed firewall->nginx route, and theoretically they could hit the firewall’s IP address but I configured Plex to consider music.mydomain.com as its external address so that I could get plexamp/plex mobile to work outside of my home network. (in order to do so, I set the “custom server access URLs” setting. I found if I didn’t do that, everything tried to connect to that internal VLAN IP Address and so nothing worked: neither on my internal network nor externally)

The strange thing to me is that the normal plex android app is able to connect to the Chromecast successfully - what is the difference between how the standard Plex app executes chromecast connectivity and how plexamp does it? If I knew that, I might be able to figure out what’s going on here.

Almost certainly the difference boils down in the exact URL it sends over to the Chromecast to play from. Technically multiple URLs might be valid (LAN, WAN, etc.) from the perspective of the player/caster.

1 Like

hmm, good to know - is there a way for me to control what it uses? In my setup, I still need the “custom server access URLs” setting to be music.mydomain.com so that I can use my apps outside of my network - but if there’s a way to specify the specific IP address to use for internal communication and/or force it to not use that external URL for internal network communication, I’m all in for that.

I did find that before I had the custom server access URL set, it would use my private VLAN address (192.168.2.245) instead of the rest-of-the-network accessible firewall IP address of 192.168.86.100, which caused me to be unable to use Plex (as nothing but the firewall and nginx can actually reach 192.168.2.245) in general until I added that setting to force what URL it connected through.

Oh snap I think this is the key to it. Thank you for talking this through with me, it made me realize that this plex.direct URL it’s using is something I didn’t explore further.

I found that after I pinged that on my internal network, it was trying to get to 192.168.2.245, which is inaccessible locally. I need to do some investigating to figure out how this plex.direct is even a registered DNS entry to begin with, and how that all works. Maybe I can reconfigure that. Is there somewhere that I can control whatever’s setting up plex.direct as a DNS entry? I don’t recall setting that up myself

Oh, if I ping just plex.direct and not that whole subdomain etc… it’s an external IP address. Interesting. Okay, so this must be a router you folks control, good to know. Okay let me see if I can just go ahead and open that port directly to that VM via NAT, maybe that’ll work… EDIT: oh wait, no I can’t do that because it’s trying to get to that internal IP address and not to the Firewall, so the firewall’s never going to see it. Okay, let me chew on this a bit and think of what I can do here. If you have any suggestions, let me know!

Okay, I found the setting that disables the relay entirely. When I did that, I was able to connect to Chromecast via the plexamp app, but when I tried to play a song the loading spinner would spin indefinitely. Then when I went to try and grab the plexamp logs, I went to Debugging → Share Logs and it showed a message that said just “Something went wrong” with a checkmark above it.

EDIT I got the logs eventually after trying a few times, going to check them out after I attend to a crying baby :smiley:

Shoot, scratch that - it only gave me logs because I force closed the app and reopened it, and in doing so it seems to have cleared whatever was happening during the Chromecast connection. I’m unable to successfully get logs while the app is still open in this scenario where the UI made it look like I made a Chromecast connection.

However, after restart I was able to try to connect again, and got the same error as I was getting before. This time there’s no plex.direct requests, but that .230 IP address it’s trying to hit is my own phone - the one running the plexamp app - strangely enough. It’s like it’s also trying to connect via HTTP to itself?

Sep 05, 2021 14:50:21.326 [Javascript] INFO - Server Activity: Connected to [SERVER ID]
Sep 05, 2021 14:50:22.311 [Javascript] INFO - Cast: State is currently NotConnected.
Sep 05, 2021 14:50:22.311 [Javascript] INFO - Cast: Starting new session.
Sep 05, 2021 14:50:22.866 [Javascript] INFO - PlayQueue: Saving state {“source”:"[SERVER ID]",“state”:“playing”,“time”:5400,“rate”:1,“volume”:100,“playQueueID”:“49”,“playQueueVersion”:1,“playQueueItemID”:“1311”}
Sep 05, 2021 14:50:22.867 [Javascript] INFO - Player: Ignoring event local playing
Sep 05, 2021 14:50:24.481 [Javascript] INFO - Cast: Session started.
Sep 05, 2021 14:50:24.482 [Javascript] INFO - Cast: Session started.
Sep 05, 2021 14:50:24.482 [Javascript] INFO - Cast: Starting channel.
Sep 05, 2021 14:50:24.486 [Javascript] INFO - Cast: Successfully connected to [LIVING ROOM CHROMECAST ID].
Sep 05, 2021 14:50:24.486 [Javascript] INFO - Audio Route: Switched over to player Living Room (volume: undefined).
Sep 05, 2021 14:50:24.486 [Javascript] INFO - Cast: using https / undefinedmusic.mydomain.com / 443 for connection URI https://music.mydomain.com:443.
Sep 05, 2021 14:50:24.563 [0x21918cc0] DEBUG - Networking: Completed request 95: (GET https://music.mydomain.com:443/security/token?type=delegation&scope=all&includeFields=thumbBlurHash&X-Plex-Device-Name=Android) with code 200 (have 86 bytes) in 65 ms.
Sep 05, 2021 14:50:24.666 [Javascript] INFO - Cast: unknown player state.
Sep 05, 2021 14:50:24.667 [Javascript] INFO - Cast: Got event for state stopped.
Sep 05, 2021 14:50:24.668 [Javascript] INFO - Audio Route: Waiting for something other than stopped, currently stopped.
Sep 05, 2021 14:50:24.787 [Javascript] INFO - Cast: unknown player state.
Sep 05, 2021 14:50:24.906 [Javascript] INFO - Cast: unknown player state.
Sep 05, 2021 14:50:24.914 [Javascript] INFO - Cast: unknown player state.
Sep 05, 2021 14:50:24.921 [Javascript] INFO - Cast: unknown player state.
Sep 05, 2021 14:50:25.912 [Javascript] INFO - Player: Ignoring event local playing
Sep 05, 2021 14:50:28.686 [Javascript] INFO - PlayQueue: Saving state {“source”:"[SERVER ID]",“state”:“playing”,“time”:11200,“rate”:1,“volume”:100,“playQueueID”:“49”,“playQueueVersion”:1,“playQueueItemID”:“1311”}
Sep 05, 2021 14:50:28.688 [Javascript] INFO - Player: Ignoring event local playing
Sep 05, 2021 14:50:31.022 [Javascript] INFO - DEVICE: Finding best connection for Pixel 3a a600c87b697a5e1f-com-plexapp-android.
Sep 05, 2021 14:50:31.026 [0x21918cc0] DEBUG - Networking: Completed request 96: (GET http://192.168.86.230:32500/resources) with code -7 (have 0 bytes) in 3 ms.
Sep 05, 2021 14:50:31.031 [Javascript] WARNING - DEVICE: Player connection http://192.168.86.230:32500 didn’t work for Pixel 3a: HTTP status -7
Sep 05, 2021 14:50:31.031 [Javascript] WARNING - DEVICE: Connection testing failed for Pixel 3a
Sep 05, 2021 14:50:31.494 [Javascript] INFO - Player: Ignoring event local playing
Sep 05, 2021 14:50:33.675 [Javascript] INFO - DEVICE: Persisting devices because Pixel 3a was dirty.
Sep 05, 2021 14:50:33.675 [Javascript] INFO - DEVICE: Persisting devices.
Sep 05, 2021 14:50:34.086 [Javascript] INFO - PlayQueue: Saving state {“source”:"[SERVER ID]",“state”:“playing”,“time”:16600,“rate”:1,“volume”:100,“playQueueID”:“49”,“playQueueVersion”:1,“playQueueItemID”:“1311”}
Sep 05, 2021 14:50:34.087 [Javascript] DEBUG - PlayQueue: Processing send timelines in state playing time 16600.
Sep 05, 2021 14:50:34.087 [Javascript] INFO - ViewState: Progress 11% (16600 ms) on item [SERVER ID]/1514.
Sep 05, 2021 14:50:34.087 [Javascript] INFO - ViewState: Trying to send directly.
Sep 05, 2021 14:50:34.087 [Javascript] INFO - Player: Ignoring event local playing
Sep 05, 2021 14:50:34.151 [0x21918cc0] DEBUG - Networking: Completed request 97: (GET https://music.mydomain.com:443/:/timeline?state=playing&duration=146786&time=16600&playQueueItemID=1311&key=%2Flibrary%2Fmetadata%2F1514&ratingKey=1514&playQueueID=49&playQueueVersion=1&containerKey=%2FplayQueues%2F49&hasMDE=1&includeFields=thumbBlurHash&X-Plex-Device-Name=Android) with code 200 (have 150 bytes) in 51 ms.
Sep 05, 2021 14:50:34.159 [Javascript] INFO - ViewState: Server reports playback state ignore.
Sep 05, 2021 14:50:34.682 [Javascript] INFO - Audio Route: Issued play, waited for start with success false.
Sep 05, 2021 14:50:34.682 [Javascript] INFO - Cast: Sending message ‘STOP’.
Sep 05, 2021 14:50:34.683 [Javascript] WARNING - Audio Route: Error switching player to Living Room.

I think the key part is:

Sep 05, 2021 14:50:24.486 [Javascript] INFO - Cast: using https / undefinedmusic.mydomain.com / 443 for connection URI https://music.mydomain.com:443.

Can you tell me exactly what the URI is?

1 Like

Thanks so much for all your help with this. Just PM’d it to you, wasn’t sure if I should post it on the forums.

I also thought that “undefined” part was interesting. I chalked it up to maybe something missing in a printf statement or what-not, just because that’s not part of the actual URL I put into the settings.

1 Like

I’m running a near identical reverse proxy config for my Plex server and have the same exact issue with Plexamp and Chromecast. Did you end up finding any resolution to this issue?

Oy yeah, admittedly I ended up having it connect straight to my plex and removing my VLAN/reverse proxy/pfsense forwarding setup. Once I did, that worked. It sounds like it’s something they’re taking a look into fixing with plexamp as somehow it works for the normal plex app but not plexamp (or at least, it did for me), but no ETA.

Does the normal plex app work in your setup?

(I also found that I was having trouble sustaining a connection if it was video - because it turned out it was going out to the internet and then all the way back in, and that was causing some trouble. But just for video? Either way, that got fixed up as well when I pulled my Plex server out of the VLAN and exposed it directly)

Ahh got it, looks like I’m waiting for a fix then. The normal Plex app works fine for me throughout, including chromecast functionality for both video and audio.

I have the same “undefined” prepend showing up on the URL in the plexamp logs so I do wonder if the problem lies there somewhere.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.