BloodyMods / ServerStarter

MIT License
99 stars 62 forks source link

Allow for configurable connection/read timeouts for the downloader. #32

Closed luckcolors closed 2 years ago

luckcolors commented 3 years ago

Hello. It seems that for wichever reason the connection betwhen my server and the forge download server has been very bad lately.

This seems to result in the serverstarter tool reaching the connection timeouts you set here: https://github.com/BloodyMods/ServerStarter/blob/be94470e4b51e06660d9d973af5484632d31d355/src/main/kotlin/atm/bloodworkxgaming/serverstarter/InternetManager.kt#L14 I can verify that this is indeed the issue by trying to wget the forge installer file manually, and i can see that connection or download can hang for more then 30 seconds, but it does after a while resume (or connects) and eventually the download finishes.

Is there any way to change these timeouts without recompiling? If not, would it be possible to add this in the configuration file (or via a flag is you prefer).

Thank you for your work in making this tool. :)

Error logs:

[20:45:12] [ERROR] Problem while installing Forge

[20:38:28] [INFO] Attempting to download forge installer from http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.16.4-35.1.36/forge-1.16.4-35.1.36-installer.jar
[20:38:58] [ERROR] Problem while installing Forge

java.net.SocketTimeoutException: connect timed out
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
        at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:240)
        at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:160)
        at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
        at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
        at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
        at okhttp3.RealCall.execute(RealCall.java:77)
        at atm.bloodworkxgaming.serverstarter.InternetManager.downloadToFile(InternetManager.kt:51)
        at atm.bloodworkxgaming.serverstarter.ForgeManager.installForge(ForgeManager.kt:110)
        at atm.bloodworkxgaming.serverstarter.ServerStarter.startLoading(ServerStarter.kt:161)
        at atm.bloodworkxgaming.serverstarter.ServerStarterKt.main(ServerStarter.kt:195)
luckcolors commented 3 years ago

Another note: the tool currently seems to ignore wether the forge download/install went properly, so it has happened that after the download fails it still tries to start up the server, and ofc fails because there's no jarfile.

Error log:

[21:20:01] [INFO] Attempting to download forge installer from http://files.minecraftforge.net/maven/net/minecraftforge/forge/1.16.4-35.1.36/forge-1.16.4-35.1.36-installer.jar
[21:20:31] [ERROR] Problem while installing Forge

java.net.SocketTimeoutException: timeout
        at okio.Okio$4.newTimeoutException(Okio.java:232)
        at okio.AsyncTimeout.exit(AsyncTimeout.java:285)
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:241)
        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:355)
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:227)
        at okhttp3.internal.http1.Http1Codec.readHeaderLine(Http1Codec.java:215)
        at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:88)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
        at okhttp3.RealCall.execute(RealCall.java:77)
        at atm.bloodworkxgaming.serverstarter.InternetManager.downloadToFile(InternetManager.kt:51)
        at atm.bloodworkxgaming.serverstarter.ForgeManager.installForge(ForgeManager.kt:110)
        at atm.bloodworkxgaming.serverstarter.ServerStarter.startLoading(ServerStarter.kt:161)
        at atm.bloodworkxgaming.serverstarter.ServerStarterKt.main(ServerStarter.kt:195)
Caused by: java.net.SocketException: Socket closed
        at java.net.SocketInputStream.read(SocketInputStream.java:204)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at okio.Okio$2.read(Okio.java:140)
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
        ... 23 more
[21:20:31] [INFO] Starting to installing Additional Files
[21:20:31] [INFO] Starting to copy local files.
[21:20:31] [INFO] Starting Forge, output incoming
Error: Unable to access jarfile /data/forge-NONE-NONE.jar
BloodWorkXGaming commented 3 years ago

The new updates should fix both issues, but I currently don't have much time to test it and trouble constructing a similar environment to you.

If you have time it would be really awesome if you could test the new build: serverstarter-2.0.0.zip

You might need to change the config to yours, as it has a testing config file. Thank you in advance :)