lyarenei / jellyfin-plugin-listenbrainz

ListenBrainz plugin for Jellyfin.
MIT License
75 stars 3 forks source link

Retry submitting listens on server error #7

Closed Maxr1998 closed 2 years ago

Maxr1998 commented 2 years ago

I've noticed ListenBrainz throws a "Bad Gateway" server error from time to time:

[DBG] [39] Jellyfin.Plugin.Listenbrainz.ServerEntryPoint: Raw response: {"code":503,"error":"Cannot submit listens to queue, please try again later."}

In that case, the plugin should retry submitting that listen, preferably with exponential backoff. Alternatively, it could print the whole listen data to the console as JSON so that you could manually re-submit the listen at a later date.

lyarenei commented 2 years ago

Hi, thanks for reporting.

the plugin should retry submitting that listen, preferably with exponential backoff.

I agree, I'll look into that when I have some free time.

Alternatively, it could print the whole listen data to the console as JSON so that you could manually re-submit the listen at a later date.

Personally, I think it would be best to implement some sort of cache and have a scheduled job to retry submitting these. However, I'm not sure if this is something a Jellyfin plugin can do self-contained (i.e. work with sqlite db/external files - holding it in memory is not much of an improvement). But even if this would be possible, I'd like to clean up the source code first as it's a mess and I've been working with c# for some time now and gained some experience.

Anyway, the raw request printing looks like a good stopgap solution (and maybe it would be also useful in debugging). So I'll implement that one as well.

Maxr1998 commented 2 years ago

Awesome, thanks for the response and planning to look into it!

lyarenei commented 2 years ago

Implemented retries and improved logging in plugin ver:

The repository in JF UI should report these new versions, so you should be able to easily upgrade the plugin.

Note that I left the old logging there, so there will be some redundant/useless logs - these will be probably removed in the big code cleanup mentioned earlier.

I'll be closing this issue for now. Feel free to reopen if you notice any relevant issues.

Maxr1998 commented 2 years ago

Awesome, thanks a lot for adding this! Will upgrade momentarily and report back in case I notice any issues.