mynttt / UpdateTool

A tool to update the IMDB ratings for Plex libraries that contain movies/series and use the IMDB agent to receive ratings
GNU General Public License v3.0
250 stars 12 forks source link

docker version terminates when no internet connection #91

Closed ghost closed 2 years ago

ghost commented 2 years ago

when no internet connection is available, there is no error handling and the program terminates on an error, causing the docker version to shut down. Could this be resolved?

2022-04-12 15:31:50,stdout,[ERROR] - 2022-04-12 15:31:50 @ ImdbDockerImplementation$ImdbBatchJob.run: The application will terminate now.

2022-04-12 15:31:50,stdout,[ERROR] - 2022-04-12 15:31:50 @ ImdbDockerImplementation$ImdbBatchJob.run: ========================================

2022-04-12 15:31:50,stdout, at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/java.util.ArrayList.forEach(Unknown Source)

2022-04-12 15:31:50,stdout, at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.lambda$run$3(Unknown Source)

2022-04-12 15:31:50,stdout, at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.handleEvent(Unknown Source)

2022-04-12 15:31:50,stdout, at java.net.http/jdk.internal.net.http.PlainHttpConnection$ConnectEvent.handle(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

2022-04-12 15:31:50,stdout,Caused by: java.net.ConnectException: Connection refused

2022-04-12 15:31:50,stdout, at java.base/java.lang.Thread.run(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)

2022-04-12 15:31:50,stdout, at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)

2022-04-12 15:31:50,stdout, at updatetool.TaskWrapper.run(Main.java:252)

2022-04-12 15:31:50,stdout, at updatetool.imdb.ImdbDockerImplementation$ImdbBatchJob.run(ImdbDockerImplementation.java:276)

2022-04-12 15:31:50,stdout, at updatetool.imdb.ImdbPipeline.(ImdbPipeline.java:113)

2022-04-12 15:31:50,stdout, at updatetool.common.externalapis.TmdbApiV3.(TmdbApiV3.java:37)

2022-04-12 15:31:50,stdout, at updatetool.common.externalapis.TmdbApiV3.tmdbId2imdbId(TmdbApiV3.java:109)

2022-04-12 15:31:50,stdout, at updatetool.common.externalapis.AbstractApi.send(AbstractApi.java:56)

2022-04-12 15:31:50,stdout, at java.net.http/jdk.internal.net.http.HttpClientFacade.send(Unknown Source)

2022-04-12 15:31:50,stdout, at java.net.http/jdk.internal.net.http.HttpClientImpl.send(Unknown Source)

2022-04-12 15:31:50,stdout,[ERROR] - 2022-04-12 15:31:50 @ ImdbDockerImplementation$ImdbBatchJob.run: java.net.ConnectException: Connection refused

2022-04-12 15:31:50,stdout,[ERROR] - 2022-04-12 15:31:50 @ ImdbDockerImplementation$ImdbBatchJob.run: ========================================

2022-04-12 15:31:50,stdout,[ERROR] - 2022-04-12 15:31:50 @ ImdbDockerImplementation$ImdbBatchJob.run: Please contact the maintainer of the application with the stacktrace below if you think this is unwanted behavior.

2022-04-12 15:31:50,stdout,[ERROR] - 2022-04-12 15:31:50 @ ImdbDockerImplementation$ImdbBatchJob.run: ConnectException exception encountered...

mynttt commented 2 years ago

@owanneke Is this still an issue that needs to be adressed or has this sorted itself out?

nn-afly commented 2 years ago

Getting a very similar error here. Did loads on its first go (1700 movies,300 shows) and then died (didnt update plex) booted again and updated plex but now i get this every boot. I may of got myself blocked by tmdb perhaps? Either way, i wonder if would be better for the container to chill and try later rather that stop? I can see you are in a tricky spot with it as if the API is wrong then bombing out is a good way to let someone know some thing is wrong

` VERSION 1.6.6 IS UP TO DATE!

MAX JVM HEAP: -Xmx256m

Enabled native Plex SQLite binary for use in write access!

Invoking tool! Logs in /config

[INFO ] - 2022-07-03 13:17:00 @ Main.loadImplementation: Loaded implementation << imdb-docker << updatetool.imdb.ImdbDockerImplementation

[INFO ] - 2022-07-03 13:17:00 @ Main.main: Running version: 1.6.6

[INFO ] - 2022-07-03 13:17:00 @ Main.main: Args: {imdb-docker={schedule=12}}

[INFO ] - 2022-07-03 13:17:00 @ Main.main: << INIT: imdb-docker @ {schedule=12} >>

[INFO ] - 2022-07-03 13:17:06 @ TmdbApiV3.: Testing TMDB API (v3) key: REDACTED

[ERROR] - 2022-07-03 13:17:11 @ Main.lambda$main$1: Uncaught HttpConnectTimeoutException exception encountered...

[ERROR] - 2022-07-03 13:17:11 @ Main.lambda$main$1: Please contact the maintainer of the application with the stacktrace below if you think this is unwanted behavior.

[ERROR] - 2022-07-03 13:17:11 @ Main.lambda$main$1: ========================================

[ERROR] - 2022-07-03 13:17:11 @ Main.lambda$main$1: java.net.http.HttpConnectTimeoutException: HTTP connect timed out

at java.net.http/jdk.internal.net.http.HttpClientImpl.send(Unknown Source)

at java.net.http/jdk.internal.net.http.HttpClientFacade.send(Unknown Source)

at updatetool.common.externalapis.AbstractApi.send(AbstractApi.java:56)

at updatetool.common.externalapis.TmdbApiV3.tmdbId2imdbId(TmdbApiV3.java:109)

at updatetool.common.externalapis.TmdbApiV3.<init>(TmdbApiV3.java:37)

at updatetool.imdb.ImdbDockerImplementation.bootstrap(ImdbDockerImplementation.java:108)

at updatetool.Main.main(Main.java:86)

Caused by: java.net.http.HttpConnectTimeoutException: HTTP connect timed out

at java.net.http/jdk.internal.net.http.MultiExchange.toTimeoutException(Unknown Source)

at java.net.http/jdk.internal.net.http.MultiExchange.getExceptionalCF(Unknown Source)

at java.net.http/jdk.internal.net.http.MultiExchange.lambda$responseAsyncImpl$7(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.uniHandle(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)

at java.net.http/jdk.internal.net.http.Exchange.checkCancelled(Unknown Source)

at java.net.http/jdk.internal.net.http.Exchange.cancel(Unknown Source)

at java.net.http/jdk.internal.net.http.MultiExchange.cancel(Unknown Source)

at java.net.http/jdk.internal.net.http.PlainHttpConnection$ConnectTimerEvent.handle(Unknown Source)

at java.net.http/jdk.internal.net.http.HttpClientImpl.purgeTimeoutsAndReturnNextDeadline(Unknown Source)

at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(Unknown Source)

Caused by: java.net.ConnectException: HTTP connect timed out

at java.net.http/jdk.internal.net.http.MultiExchange.toTimeoutException(Unknown Source)

at java.net.http/jdk.internal.net.http.MultiExchange.getExceptionalCF(Unknown Source)

at java.net.http/jdk.internal.net.http.MultiExchange.lambda$responseAsyncImpl$7(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.uniHandle(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture$UniHandle.tryFire(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)

at java.net.http/jdk.internal.net.http.Exchange.checkCancelled(Unknown Source)

at java.net.http/jdk.internal.net.http.Exchange.cancel(Unknown Source)

at java.net.http/jdk.internal.net.http.MultiExchange.cancel(Unknown Source)

at java.net.http/jdk.internal.net.http.PlainHttpConnection$ConnectTimerEvent.handle(Unknown Source)

at java.net.http/jdk.internal.net.http.HttpClientImpl.purgeTimeoutsAndReturnNextDeadline(Unknown Source)

at java.net.http/jdk.internal.net.http.HttpClientImpl$SelectorManager.run(Unknown Source)

[ERROR] - 2022-07-03 13:17:11 @ Main.lambda$main$1: ========================================

[ERROR] - 2022-07-03 13:17:11 @ Main.lambda$main$1: The application will terminate now. (Version: 1.6.6)

`

mynttt commented 2 years ago

@nn-afly I have thought about this and implementing a flag to disable this behavior is not a smart idea. The tool is required to have an internet connection - it just does not work otherwise.

I will however change the behavior of the docker container so that if you pass a special flag to it, it won't stop the container but restart the java application inside of it automatically after it crashes. In this case maybe if internet is available again the problem will take care of itself.

mynttt commented 2 years ago

@nn-afly @owanneke

You can now supply the docker this environment variable: RESTART_ON_CRASH and set its value to true. In case the tool crashes it will now not stop the docker but wait 10 seconds before launching the tool again and thus handling crashes more gracefully.

With your internet connection issues this will hopefully at some point make the tool work again once a connection can be established.

nn-afly commented 2 years ago

thank you @mynttt

Just as an update, after a few manual restarts the thing has been working beautifully