Athou / commafeed

Google Reader inspired self-hosted personal RSS reader.
https://www.commafeed.com
Apache License 2.0
2.73k stars 370 forks source link

Migrate to Quarkus #1520

Closed Athou closed 1 month ago

Athou commented 1 month ago

Replace Dropwizard with Quarkus

https://github.com/Athou/commafeed/discussions/1517

canoine commented 1 month ago

I meet a problem, but I don't know if the cause is this migration, or a PEBKAC :

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------

(snip)

[INFO] Running com.commafeed.backend.HttpGetterTest
Handler org.mockserver.logging.StandardOutConsoleHandler is not defined
Handler org.mockserver.logging.StandardOutConsoleHandler is not defined
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2024-08-18 11:18:36,072 INFO  [io.net.uti.int.NativeLibraryLoader] (MockServer-MockServer-workerEventLoop9) /tmp/libnetty_tcnative_linux_x86_648066554815368152247.so exists but cannot be executed even when execute permissions set; check volume for "noexec" flag; use -Dio.netty.native.workdir=[path] to set native working directory separately.
[ERROR] Tests run: 19, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 16.11 s <<< FAILURE! -- in com.commafeed.backend.HttpGetterTest
[ERROR] com.commafeed.backend.HttpGetterTest.ignoreInvalidSsl -- Time elapsed: 5.675 s <<< ERROR!
org.apache.hc.client5.http.ConnectTimeoutException: Connect to https://localhost:45819 [localhost/127.0.0.1] failed: Read timed out
    at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:288)
    at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:314)
    at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:355)
    at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:808)
    at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)
    at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:484)
    at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:478)
    at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1510)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1425)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:455)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:426)
    at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.executeHandshake(SSLConnectionSocketFactory.java:345)
    at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:313)
    at org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:251)
    at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:189)
    at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:450)
    at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:162)
    at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:172)
    at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:142)
    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
    at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:192)
    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
    at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:152)
    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
    at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
    at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
    at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:170)
    at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:245)
    at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:188)
    at com.commafeed.backend.HttpGetter.getBinary(HttpGetter.java:100)
    at com.commafeed.backend.HttpGetter.getBinary(HttpGetter.java:74)
    at com.commafeed.backend.HttpGetterTest.ignoreInvalidSsl(HttpGetterTest.java:225)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

(snip)

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   HttpGetterTest.ignoreInvalidSsl:225 » ConnectTimeout Connect to https://localhost:45819 [localhost/127.0.0.1] failed: Read timed out
[INFO] 
[ERROR] Tests run: 65, Failures: 0, Errors: 1, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for CommaFeed 5.0.0:
[INFO] 
[INFO] CommaFeed .......................................... SUCCESS [  0.120 s]
[INFO] CommaFeed Client ................................... SUCCESS [05:24 min]
[INFO] CommaFeed Server ................................... FAILURE [01:08 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:35 min
[INFO] Finished at: 2024-08-18T11:18:52+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.3.1:test (default-test) on project commafeed-server: 
[ERROR] 

Skipping the tests is sufficient to end the build.

Athou commented 1 month ago

Not sure, but there is now a SSL handshake timeout on the HTTP client that was not set on previous versions. During tests, it's set to 5s which could be too low if you're building on a slow machine (MockServer is building a SSL certificate dynamically when needed, it takes 1.5s on my machine). Could you try to increase the timeout in line Mockito.when(config.httpClient().sslHandshakeTimeout()).thenReturn(Duration.ofSeconds(5)); of com.commafeed.backend.HttpGetterTest.java to something like 30s?

canoine commented 1 month ago

Indeed, my server is a slow machine :

[INFO] Running com.commafeed.backend.HttpGetterTest
Handler org.mockserver.logging.StandardOutConsoleHandler is not defined
Handler org.mockserver.logging.StandardOutConsoleHandler is not defined
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
2024-08-18 12:00:57,213 INFO  [io.net.uti.int.NativeLibraryLoader] (MockServer-MockServer-workerEventLoop9) /tmp/libnetty_tcnative_linux_x86_645656822277209167061.so exists but cannot be executed even when execute permissions set; check volume for "noexec" flag; use -Dio.netty.native.workdir=[path] to set native working directory separately.
[INFO] Tests run: 19, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.02 s -- in com.commafeed.backend.HttpGetterTest

The build is OK :

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for CommaFeed 5.0.0:
[INFO] 
[INFO] CommaFeed .......................................... SUCCESS [  0.112 s]
[INFO] CommaFeed Client ................................... SUCCESS [01:58 min]
[INFO] CommaFeed Server ................................... SUCCESS [01:19 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:19 min
[INFO] Finished at: 2024-08-18T12:01:23+02:00
[INFO] ------------------------------------------------------------------------
Athou commented 1 month ago

Thanks! https://github.com/Athou/commafeed/commit/b88e5d2847a87b194d970afa5351950182fa6012

canoine commented 1 month ago

Works well now. Thank you.

canoine commented 1 month ago

Dumb question, but perhaps useful for other sysadmins : could you be more precise about the application.properties location, and its syntax, please ? I tried several directories, and commafeed always ignores it. So I use an .env file, successfully. Perhaps you could add an example into the tree ?

Athou commented 1 month ago

I guess you tried to configure the JDBC url and it didn't work, because I just tried and it was not working for me either, until I realized I made a mistake in the README https://github.com/Athou/commafeed/commit/e6dd088abe335a4deabb8f9a90dd39c5cbd79008 I'm sorry 😢

It worked with the .env because both . and - should be _ in env variables.

canoine commented 1 month ago

OK, no problem. Let's try. :) Another question : is there an equivalent to "publicUrl:" (config.yml) for an instance behind a reverse proxy ?

Athou commented 1 month ago

It's not needed anymore, the value was only used in contexts where the HTTP request was available so now it's extracted from the request. Your reverse proxy needs to forward the hostname though, I think via the Host header. Caddy does this automatically, you have to configure it manually for nginx and httpd.

canoine commented 1 month ago

OK for application.properties. Thank you. The config directory must be in the same place than quarkus-run.jar.

Concerning the reverse proxy trick, nginx does it by defaut. Indeed, all seems to work well... All but the redirection to the login page after disconnection, where there's no URL rewriting.

Athou commented 1 month ago

I think you need those two nginx directives for it to work:

proxy_set_header Host $host; proxy_set_header X_FORWARDED_PROTO https;

canoine commented 1 month ago

Oh yes ! I inadvertently deleted the second directive during a config update, it seems. Sorry, that works.

Athou commented 1 month ago

I just added a link to this in the README https://github.com/Athou/commafeed/blob/master/commafeed-server/doc/commafeed.adoc It's not very sexy yet but it should help.

canoine commented 1 month ago

Nice ! That's much more understandable. Thank you.