vosmiic / jellyfin-ani-sync

Synchronize anime watch status between Jellyfin and anime tracking sites.
GNU General Public License v3.0
214 stars 15 forks source link

Timeout #103

Closed stefandesu closed 4 months ago

stefandesu commented 5 months ago

Describe the bug

Recently, the plugin hasn't been working as consistently as before, apparently with HTTP requests timing out.

Logs

[2024-01-24 17:13:37.703 +00:00] [ERR] [293] jellyfin_ani_sync.SessionServerEntry: Fatal error occured during anime sync job: System.Threading.Tasks.TaskCanceledException: The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing.
 ---> System.TimeoutException: The operation was canceled.
 ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled.
 ---> System.IO.IOException: Unable to read data from the transport connection: Operation canceled.
 ---> System.Net.Sockets.SocketException (125): Operation canceled
   --- End of inner exception stack trace ---
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
   at System.Net.Security.SslStream.EnsureFullTlsFrameAsync[TIOAdapter](TIOAdapter adapter)
   at System.Net.Security.SslStream.ReadAsyncInternal[TIOAdapter](TIOAdapter adapter, Memory`1 buffer)
   at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpConnection.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts)
   at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
   at jellyfin_ani_sync.Helpers.AnimeOfflineDatabaseHelpers.GetProviderIdsFromMetadataProvider(HttpClient httpClient, Int32 metadataId, Source source)
   at jellyfin_ani_sync.UpdateProviderStatus.Update(BaseItem e, Guid userId, Boolean playedToCompletion)
   at jellyfin_ani_sync.SessionServerEntry.PlaybackStopped(Object sender, PlaybackStopEventArgs e)

To Reproduce

Hard to reproduce. I noticed it happening occasionally in the past two weeks or so. When I noticed it the first time, I reauthenticated my AniList account, but after it happened yesterday, the auth was still working correctly.

Expected behavior

The plugin has been working very consistently for me in 2023. I can't remember a single instance of it not doing its job.

Even if the HTTP request times out, I think it should retry the request instead of just failing.

Desktop (please complete the following information):

No recent changes to the system that could have caused this issue. AFAIK no issues with my internet connection either.

vosmiic commented 5 months ago

Hi, does the log give any kind of indication as to what request is timing out? Is it consistently a single type of request, or does it vary?

stefandesu commented 5 months ago

Unfortunately, the log above is the only thing I could find, unless there's some hidden log file with additional info.

Yesterday evening it worked without having changed anything. I'll keep an eye on it and report back when it happens again!

vosmiic commented 5 months ago

Unfortunately, the log above is the only thing I could find, unless there's some hidden log file with additional info.

Yesterday evening it worked without having changed anything. I'll keep an eye on it and report back when it happens again!

Great, thanks. If you hit into it again, including the previous messages that were logged by the plugin should help in finding the stage the plugin was at when syncing and could help find the culprit API call. We use a few API calls during the sync so it would be great to nail it down to a single problematic call.

vosmiic commented 4 months ago

Going to close this as its nearly been a month, if you hit into the issue again feel free to open it again