FoxxMD / multi-scrobbler

Scrobble plays from multiple sources to multiple clients
https://foxxmd.github.io/multi-scrobbler
MIT License
433 stars 18 forks source link

Docker-Compose with Maloja #37

Closed jackbcohen closed 2 years ago

jackbcohen commented 3 years ago

Hello! I'm trying to run multi-scrobbler and maloja in a docker-compose file, but am having trouble getting MS to see maloja or authenticate with spotify. The web interfaces both boot up. The Spotify auth let me log in one time, and now when I click it shows "OK" on a white screen, but I get an error message in the console - "[Source - Spotify - unnamed] Cannot start polling because user interaction is required for authentication." When I try to reauth with Maloja, I get this error - "Specified client does not have auth implemented (maloja)" My best guess is that the docker network is configured incorrectly, but I'm hoping you can help me. Attaching docker-compose for reference. Thank you so much! maloja-docker-compose.zip !

FoxxMD commented 2 years ago

For the spotify issue

Check that, after logging in, there was a .json file created in /mnt/comet/docker/multi-scrobbler/config that looks something like currentCreds-[spotifySourceName].json -- MS saves the credentials returned from the spotify authorization process. Make sure that your container can write to this directory in order to save the credentials file.

Also double check the URL you access MS on. The domain:port used in SPOTIFY_REDIRECT_URI should be the same as whatever you are using to access the MS web interface from your host machine.

For maloja auth

This one I'm not too sure about as I don't use compose often. The default network mode for compose is bridge so only ports exposed for each service are reachable. However I'm not sure if that only applies to external (host) usage or not. You can try using the service alias so try this instead MALOJA_URL: http://maloja:42010


Additionally, you can try to get more info from MS by adding the environment variable LOG_LEVEL: debug

jackbcohen commented 2 years ago

Thank you so much for offering this help, it's gotten me a lot further! Right now, I have Spotify auth working perfectly through MS. Connecting to Maloja is still giving me some trouble, though - even with static IP addresses, MS is throwing an error when trying to connect to Maloja. I've gotten it to work, but when I restart the containers, it likes to fail again.

Error message I am seeing:

error : [Client Maloja - unnamed] Error: connect ECONNREFUSED 172.30.0.2:42010 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) 2021-12-08T06:04:30+00:00 error : [Client Maloja - unnamed] Error: connect ECONNREFUSED 172.30.0.2:42010 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) 2021-12-08T06:04:30+00:00 error : [Client Maloja - unnamed] Auth test failed

Docker-compose is attached so you can see how I tried to brute-force the networking to get them to reliably see each other, but no luck. docker-compose (copy).zip

FoxxMD commented 2 years ago

I've gotten it to work, but when I restart the containers, it likes to fail again.

So you have had it successfully connect using the configuration you have provided, but when starting the containers initially it does not work?

I, personally, have an issue with maloja's startup performance that might be the same as what you are experiencing...

When Maloja starts up it first parses all of the scrobbles available to it to build an in-memory database (from .tsv files storing all scrobbles). I've found, for me at least, that this process is very slow. Consequently, the web interface (api) is not available until after this build process is done.

So my recommendation would be to start maloja first and delay MS startup.

You can attempt this manually by, I think, by doing

If this works reliably for you it looks like there are a few solutions for automating the delay process, detailed in the compose docs

jackbcohen commented 2 years ago

You're amazing, looks like that delay was the issue. Interestingly, if you just restart maloja or multiscrobbler independently, it won't re-connect. But Maloja first, waiting for the cpu spike/ram load to stop and then loading MS worked perfectly.

Thanks so much for your help, this is absolutely amazing and I'm really excited.

One other random question but really feel free to ignore: does Maloja cache images locally? I'd love if it could just download everything to the /config directory so that the loading times are a bit faster. Also, is there a way to make sure that you're pulling from the Spotify API?

FoxxMD commented 2 years ago

I'm not super familiar with the innerworkings of maloja but from what I can tell from a quick peek in my own config folder...

does Maloja cache images locally?

There is a /config/cache folder that contains two files named imgcache_* . It looks like Maloja gets artwork URLs from whatever provider you use (spotify) and then caches the URL in association with the artist/track -- but not the actual image files.

is there a way to make sure that you're pulling from the Spotify API?

I believe if you add LOGGING = true to your settings file (/config/settings/settings.ini) Maloja logs more stuff. In my /config/logs folder there is a spotify.log file that has output saying "successfully authenticated with spotify". I imagine if there was some issue it would probably output it there too.

FoxxMD commented 2 years ago

@jackbcohen I've implemented a more granular readiness check for Maloja in 9bc6f44af486c04cadf533fbc5fe874c5bc5802c that should eliminate any need for delays. To use this:

For now you will see this in the logs when MS tries to use the maloja client until Maloja finishes building the database:

[Client Maloja - default] Server is not ready: Server is rebuilding database
[Client Maloja - default] Could not test auth because server is not ready
[Scrobblers             ] Cannot scrobble to Client 'default' because auth test failed

There should be another update soon, dependent on a PR merge for Maloja, that will make the "server not ready" test not depend on auth (error will be clearer)

FoxxMD commented 2 years ago

@jackbcohen update to maloja 12.12.19 and latest MS image. You can remove any delays now and logs should be clear about maloja rebuild status. The client will automatically start scrobbling once the database is ready.

jackbcohen commented 2 years ago

@FoxxMD Working perfectly with both docker images on latest.

Thanks so much for your work on this and maloja - loving the setup and software!