kaaholst / android-squeezer

Remote control for your Logitech Media Server ("Squeezeserver" etc) and players.
Apache License 2.0
75 stars 15 forks source link

Frequent disconnections #819

Open luanthom opened 2 months ago

luanthom commented 2 months ago

I experience frequent disconnections or reconnection requests when switching to the app. I am currently using Google Pixel 7a but had the issue on previous phones e.g. Motorola G9

The scenario is that I am using the app with LMS 8.4 (and previous versions), over wifi. This may be listening to radio or random playlists etc. The app is fine to start with and responds correctly when I switch to it (maybe every 5 mins or so). However after a while, I start to get the server reconnect screen. Reconnecting works fine but becomes increasingly frequent until it no longer reconnects. However, force stopping the app and re-opening works and normal operation resumes - but eventually it will start to have problems connecting again.

It reminds me of a similar problem in a commercial application middle tier I was involved with, where the connection pool becomes full of broken connections which require requires a reboot of the middle tier.

kaaholst commented 2 months ago

Thanks for the feedback.

I think the issue is similar to what you describe. If for some, maybe valid reason the connection to LMS is broken, and a new connection is successfully created, then the previous fail is somehow stuck and forces a disconnect of the new connection. I'm currently looking into a solution to remove all reminiscences of previous connections whenever we get a successful connection.

StewLG commented 1 month ago

I have recently started to have frequent disconnects that force me to restart the Squeezer app when first trying to run it. I've seen this issue in the past, but recently it's gotten much worse. It seems to be related to the fact that I'm running two different LMS servers on two independent WiFi networks in two different houses.

The issue happens seemingly 100% of the time when I first arrive at house B having using Squeezer at house A, or vice-versa. I'll toggle into an already-running Squeezer, it will at first be looking for the prior server on a different IP and not finding it - a completely understandable failure. But then I'll select the correct server from the "Choose a server" dropdown, and it will briefly connect to the server, show the current playlist and menus - then within 1-2 seconds, disconnect again. I can repeat this over & over, hitting connect repeatedly and failing to stay connected.

Usually if I exit the app and re-run, all is immediately well, it finds the current server and does not disconnect.

I once or twice have resorted to restarting the phone, but can't say for sure if that's relevant - it might have been superstition stemming from frustration.

I will run debug builds or do whatever you need to diagnose the issue, but there's nothing special about my situation I wouldn't think except that I have two full setups. I figure it's reproducible if one took the time to fake up the same thing with two servers, possibly on two networks.

kaaholst commented 1 month ago

Thanks for the detailed descriptions.

Please try this apk.

When you are done testing, you may continue to use this apk, it will automatically be updated when a new version is released.

StewLG commented 1 month ago

Sorry for the delay in responding, I can only test when I move between houses.

Yesterday I moved from house A to house B. House B has a simple WiFi network configuration, issuing IPs on the same single subnet as the wired network, so the LMS server discovery stuff works properly there. House B LMS server was recognized and I was able to connect without disconnects the first time. So that seems better. I will re-test this circumstance again soon and will report if I see anything different.

This morning I moved from house B to house A. House A has a relatively complicated WiFi network configuration, with IPs issued on a different subnet from the wired stuff, so the wired LMS server isn't on the same subnet as my phone's wireless client. Squeezer took about 5 minutes (maybe?) to recognize that it was disconnected, before which time it just let me work through menus that were all empty or blank, play and stop commands ignored/impotent, with no general recognition that house B LMS server had disappeared. In the past this disconnection recognition seemed immediate.

Once I was disconnected, I manually reconnected to house A LMS by typing in the IP address and port. Squeezer has stayed connected since, with no arbitrary disconnections and no need to restart.

Thank you for trying to fix these issues! A server bookmark feature that would save me from having to re-type the IP address ever time I come to house A would be nice.

kaaholst commented 1 month ago

OK, if I understand correctly, the frequent disconnects have disappeared. The issue with disconnection not being apparent will have to be fixed, I will look into that. Finally, we actually have a mechanism for server bookmarks. The address to connect is dependent on the BSSID. So Squeezer should actually remember the server based on the network the device is connected to. This does not work any more, however, because BSSID is considered sensitive information in Android.

kaaholst commented 1 month ago

Here is a new APK, which will show the connection page if the connection fails when Squeezer is opened. The link is the same, but the APK it points to is updated.

StewLG commented 1 month ago

This latest version seems to recognize its disconnection from the server quickly enough that it's not frustrating.

From my point of view the only thing missing now is that I have to type in the server IP and port when it isn't discoverable, which is each time I return to house A. I'm sorry the BSSID access was removed, but I would settle for Squeezer just remembering prior server addresses that worked in the "Manually enter address" drop down. These could be listed after servers that were just found in a discovery scan, and maybe eliminate dupes if it isn't too much trouble. If this leads to bad side effects for other users it could be made configurable, defaulting to off.

But the experience when the server is discoverable is totally fine now, as well as when the server is completely absent.

Thank you again for your attention to this.

@luanthom did these builds help you any?

kaaholst commented 1 month ago

Thanks for the feedback. I would like to get this out as soon as possible, because the frequent disconnections affect other users as well. Then I will investigate how we can accomplish not having to type in the server address on each connect. I think BSSID access is restricted because you can deduce location from it. It may be possible to get the information if we ask the user for permission, the same way we ask for access to phone state, so we pause play when the phone is ringing. Alternatively or in addition, I will investigate the feasibility of remembering successful connections to manually entered addresses. On a side note, if your server is using port 9000, you don't have to enter it. If no port is entered, Squeezer will attempt to connect to port 9000.

luanthom commented 2 weeks ago

This latest version seems to recognize its disconnection from the server quickly enough that it's not frustrating.

From my point of view the only thing missing now is that I have to type in the server IP and port when it isn't discoverable, which is each time I return to house A. I'm sorry the BSSID access was removed, but I would settle for Squeezer just remembering prior server addresses that worked in the "Manually enter address" drop down. These could be listed after servers that were just found in a discovery scan, and maybe eliminate dupes if it isn't too much trouble. If this leads to bad side effects for other users it could be made configurable, defaulting to off.

But the experience when the server is discoverable is totally fine now, as well as when the server is completely absent.

Thank you again for your attention to this.

@luanthom did these builds help you any?

Apologies, I've not been getting notifications so didn't see this comment (my profile email address was blank for some reason). I noticed a new apk updated on my phone today with "connection issues" in the release notes so I will look out for the improvements and give feedback here. Thanks for looking at this.