BlitterStudio / MB_SubSonic

MusicBee SubSonic plugin
GNU General Public License v3.0
110 stars 14 forks source link

Preferences not saving #7

Closed PlaidPhantom closed 7 years ago

PlaidPhantom commented 8 years ago

Hello, I seem to be having an issue where I enter my server information and then hit "Save" in the preferences window, but nothing happens. When I go back into the Preferences, the server information is reset to the default values (localhost, etc.). I'm on Windows 10.

midwan commented 8 years ago

Hi there. Could you try a simple test, to check if it helps?

If the saved file is incorrect in any way, this will help in getting it to work. If you still have a problem, let me know.

PlaidPhantom commented 7 years ago

Sorry for the delay, I've been busy.

I did not see a subsonicSettings.dat file in the MusicBee folder. As a test, I closed MusicBee, deleted the entire MusicBee folder, re-opened MusicBee, opened the Preferences and tried to re-enter my server settings. It still didn't make a subsonicSettings.dat file, but I noticed an ErrorLog.dat file was created and it had the following contents:

7/14/2016 9:28:46 PM - 10.0.10586.0 - 3.0.5977.39054 - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at MusicBeePlugin.Plugin.SaveSettings()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at MusicBee.Plugin.#=qibZyWiK8aiJzZ4auOBgbeg==()
midwan commented 7 years ago

Hmm, strange. Could you please give me some more details on your environment? Which OS version, MusicBee version, plugin version are you running?

PlaidPhantom commented 7 years ago

I'm on fully updated Windows 10, MusicBee 3.0.5977, and plugin version 2.1.

If it helps any, I'm technically not running Subsonic, I'm using Ampache with the SubSonic API backend. I'm fairly certain it's set up correctly; I'm able to connect to it from a few other apps I've tried.

midwan commented 7 years ago

Thanks for the update. I've been testing it on 2 Win10 machines almost daily for many months now, never once say this problem. I don't think the Ampache part is an issue, as your problem is saving the settings which happens on MusicBee's side of things (not the SubSonic side).

Have you tried running MusicBee as Administrator? Perhaps under a different user account if possible? I'm thinking that maybe this has to do with permissions somehow, although %APPDATA% is normally fully writable from the user.

Also, please note the latest version of MusicBee is currently 3.0.5995 (http://getmusicbee.com/download.html). Not that I think it matters, I've been testing the plugin with MB since version 2.5 without problems... :)

PlaidPhantom commented 7 years ago

Still no luck. I tried running as Administrator both before and after upgrading MusicBee, and even reinstalled the plugin from scratch. I tried to roll back to the 2.0 plugin just for kicks, but my settings failed because I'm using HTTPS.

midwan commented 7 years ago

Hm, I wonder if there's something wrong with the settings you used then. Any chance of creating an account for me and sending me the details so I can test with that?

The thing is, the settings file is saved by MusicBee itself with a mechanism that is put there for all plugins to use. The plugin will just call that ("SaveSettings()") which will trigger the creation of the settings file in %APPDATA% as described above. If that doesn't happen, something's wrong at a much earlier level already. Another reason the settings might not get saved, is that the connection details are incorrect - the connection is tested for validity when clicking on Save, if it's incorrect you should get an error message and the settings are NOT saved.

If there's a problem with your settings for your server, it should be possible to recreate on other installations as well. So my suggestion is to try your connection details on an installation that otherwise works and see what happens.

PlaidPhantom commented 7 years ago

Sure, a test user would be fine. Should I email the details to you, or something else? I hesitate to post a username and password in a public issue. :wink:

midwan commented 7 years ago

Of course you shouldn't put something like that on a public space.. I've sent you an e-mail regarding the issue. ;)

midwan commented 7 years ago

I've managed to narrow down this problem. Unfortunately, the problem is with Ampache's Subsonic implementation. It does not send back the correct response when a "ping.view" request is sent, using a Username, Token and Salt as parameters.

Perhaps it does not support this method of requests, expecting instead the (older and insecure) method of specifying username and password in the URL?

The best would be to have this implemented on that side, as providing username and password in the URL in plain text is really not a good idea. That however needs to be taken up from the developers of that application I'm afraid.

More specifically, when the plugin is requested to Apply/Save the settings, it will try to validate them by sending a "ping" request to the Subsonic API (as documented here: http://www.subsonic.org/pages/api.jsp). If that response comes back as expected, then we know that the server is available, it is indeed a Subsonic server and it supports our method of communication (username, token, salt). If not, the plugin would revert back to the last saved settings and refuse to save the new ones.

I've made a code change to notify the user if such a scenario occurs, so now you will get a requester mentioning what went wrong and actually allow you to save the settings anyway. But that won't help you I'm afraid, as in order to contact the server and get back the required information (list of tracks/albums/etc.) the same method of communication as with the "ping.view" request will be used. If it failed to respond correctly to the "ping.view", it will do so on all the other requests as well.

If you want more detailed information on the matter, I'd be happy to give it to you (perhaps to forward to the developers of Ampache's Subsonic implementation?).

PlaidPhantom commented 7 years ago

That makes sense. Thanks for the help! I've opened an issue with the Ampache devs to see if they can shed further light. Maybe once I find some free time I could build my own MusicBee/Ampache plugin. :)