Suwayomi / Suwayomi-Server

A rewrite of Tachiyomi for the Desktop
Mozilla Public License 2.0
3.93k stars 201 forks source link

[Bug] Chapter list cant be retrieved without internet using Suwayomi extension #647

Open BaccanoMob opened 1 year ago

BaccanoMob commented 1 year ago

Device information

Why?

To read manga which are downloaded or stored locally when there is no internet access

Problem 1

Starting with no internet at all

Steps to reproduce

  1. Turn off Wifi (or connect with Wifi network with no internet access or Wifi with LOS light blinking or Mobile hotspot with no data/wifi)
  2. Start tachidesk

Expected behavior

Tachidesk should start up with no problems and be able to read locally stored manga.

Actual behavior

Gives the following error and doesnt start.

22:19:20.832 [main] WARN suwayomi.tachidesk.server.util.WebInterfaceManager downloadVersion(version= r983, flavor= WebUI) -- (retry 3/3) failed due to
java.net.UnknownHostException: github.com
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:229)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.base/java.net.Socket.connect(Socket.java:609)
    at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:305)
    at java.base/sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
    at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:182)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:507)
    at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:602)
    at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
    at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:207)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1187)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:193)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:168)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.downloadVersionZipFile(WebInterfaceManager.kt:380)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.access$downloadVersionZipFile(WebInterfaceManager.kt:65)
    at suwayomi.tachidesk.server.util.WebInterfaceManager$downloadVersion$2.invoke(WebInterfaceManager.kt:362)
    at suwayomi.tachidesk.server.util.WebInterfaceManager$downloadVersion$2.invoke(WebInterfaceManager.kt:362)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.executeWithRetry(WebInterfaceManager.kt:282)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.executeWithRetry(WebInterfaceManager.kt:287)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.executeWithRetry(WebInterfaceManager.kt:287)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.executeWithRetry(WebInterfaceManager.kt:287)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.executeWithRetry$default(WebInterfaceManager.kt:280)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.downloadVersion(WebInterfaceManager.kt:362)
    at suwayomi.tachidesk.server.util.WebInterfaceManager$doInitialSetup$doDownload$1.invoke(WebInterfaceManager.kt:155)
    at suwayomi.tachidesk.server.util.WebInterfaceManager$doInitialSetup$doDownload$1.invoke(WebInterfaceManager.kt:153)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.doInitialSetup(WebInterfaceManager.kt:188)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.setupWebUI(WebInterfaceManager.kt:116)
    at suwayomi.tachidesk.server.JavalinSetup.javalinSetup$lambda$1(JavalinSetup.kt:50)
    at io.javalin.core.JavalinConfig.applyUserConfig(JavalinConfig.java:205)
    at io.javalin.Javalin.create(Javalin.java:93)
    at suwayomi.tachidesk.server.JavalinSetup.javalinSetup(JavalinSetup.kt:48)
    at suwayomi.tachidesk.MainKt.main(Main.kt:15)
    at suwayomi.tachidesk.MainKt.main(Main.kt)
22:19:20.838 [main] ERROR suwayomi.tachidesk.server.ServerSetup -- unhandled exception
java.lang.Exception: Unable to setup a webUI
    at suwayomi.tachidesk.server.util.WebInterfaceManager.doInitialSetup(WebInterfaceManager.kt:190)
    at suwayomi.tachidesk.server.util.WebInterfaceManager.setupWebUI(WebInterfaceManager.kt:116)
    at suwayomi.tachidesk.server.JavalinSetup.javalinSetup$lambda$1(JavalinSetup.kt:50)
    at io.javalin.core.JavalinConfig.applyUserConfig(JavalinConfig.java:205)
    at io.javalin.Javalin.create(Javalin.java:93)
    at suwayomi.tachidesk.server.JavalinSetup.javalinSetup(JavalinSetup.kt:48)
    at suwayomi.tachidesk.MainKt.main(Main.kt:15)
    at suwayomi.tachidesk.MainKt.main(Main.kt)

Problem 2

Start with internet but cut off due to whatever reason like Wifi LOS or temporarily use Mobile data to start Tachidesk and disable internet to read local manga (Workaround for Problem 1). Problematic when reading from Suwayomi but no issues in localhost or android browser.

Steps to reproduce

  1. Connect Turn on Mobile hotspot with data
  2. Start tachidesk
  3. Disable data
  4. Open Suwayomi extension

Expected behavior

Tachidesk should start up and runs with no problems and be able to read locally stored manga. Tachiyomi should get the manga and its chapters from Tachidesk's db.

Actual behavior

No errors for running tachidesk but there are errors in the Suwayomi extension when opening manga (no error while in android chrome browser btw)

  1. If the manga already loaded previously so chapter list is stored in Tachiyomi database, local chapters from Tachidesk can be read as long its chapter is displayed in Tachiyomi but if a reload is needed to update the manga with latest chapters we get HTTP error 500.
  2. If the manga opened for the first time in Tachiyomi, we get HTTP error 500 and chapters are not loaded (apparently chapter list are not fetched from server in Suwayomi), manga details were loaded though. Clicking manga's webview just gives name of the extension and nothing else.

Possible fix is to retrieve manga and chapter list from Tachidesk's db when reloading/refreshing to update manga in Tachiyomi if retrieving from internet fails so local chapters can atleast be read. (Not sure if i should raise an issue in Tachiyomi-extensions about this)

schroda commented 1 year ago

Problem 1

this is the expected behaviour, since you have the server setup to serve the default WebUI it fails if that is not possible. if you are not using the default WebUI or want to serve a custom one disable webUIEnabled or change webUIFlavor to Custom in the config

the error that you're running into should also only be possible if the server was never started with an internet connection before

Problem 2

You can only read chapters that you have downloaded. For every other chapter the server fetches the chapters pages information again before loading them, thus, without an internet connection it won't be possible to read the chapter, even if all pages are in the cache

BaccanoMob commented 1 year ago

Problem 1 got fixed with changing webUIFlavor to Custom in the config (I need the UI so cant set WebUIEnabled as false). Thanks!

More Info on Problem 2: I can read manga which is downloaded from Tachidesk without internet access as long as Im connected to the same wifi.

(More of a Suwayomi extension problem, mentioning it again just in case) Its just that Tachiyomi relies fully on internet to get the chapter list of any manga. So without internet if the manga is opened for the first time in Tachiyomi, then the chapter list is not retrieved. Same goes if the chapter list is outdated in the app, I cant update the list without internet. I get HTTP 500 error for both cases.

For example, I used to phone to read till Chapter 10 of some manga (which is latest at that time). In the server I downloaded till Chapter 12 while I had internet (and not updating my Tachiyomi Library). Without the internet I can read only till Chapter 10 but I cant update my chapter list in Tachiyomi to get till Chapter 12 using the Suwayomi extension.

And If I access via the browser in my phone, everything works. The chapter list is up-to-date (according to the server that is Chapter 12) and I can open any manga I want. But yes I can only read the manga I downloaded already in the server machine.

That's why I mentioned this

Possible fix is to retrieve manga and chapter list from Tachidesk's db when reloading/refreshing to update manga in Tachiyomi if retrieving from internet fails so local chapters can atleast be read.

So this way, Tachiyomi can get the Manga details and chapter list from the server itself if the extension is down or we dont have internet access. Therefore, its not a Tachidesk problem, but Suwayomi extension's problem (but Im unsure if post this in Tachiyomi-extensions or here is fine, please let me know if I made a mistake)

schroda commented 1 year ago

that is something you have to bring up at tachiyomi