Open JasonTheDynamite opened 3 months ago
I tried a similar setup based on the Vaadin Quarkus maven starter and cannot reproduce, neither in dev nor in production mode. Push script is loaded correctly and updates happen correctly without user interaction.
@JasonTheDynamite could you please share a full project that reproduces the issue as a GitHub project or attach a zip file to this issue?
Also, is the application behind some reverse-proxy that might block resources from being served to the client?
@mcollovati "Also, is the application behind some reverse-proxy that might block resources from being served to the client?" - no Attaching full reprod. The "https://192.168.1.100/VAADIN/static/push/vaadinPush.js could not be loaded. Push will not work" does not show now but pushmode is still disabled. push-issue_reprod.zip
This "https://192.168.1.100/VAADIN/static/push/vaadinPush.js could not be loaded. Push will not work." is visible when I use the websiite with ssl (https). Without SSL this message is not being displayed. Push stil is DISABLED
@JasonTheDynamite I tried your application. I am not familiar with kotlin and gradle, but here are a couple of notes
UI.access()
block (In VaadinDispatcher
you are using UI.accessSynchronously()
, I think it could be UI.access()
instead)attachEvent!!.ui.pushConfiguration.pushMode
instead of VaadinSession.getCurrent().configuration.pushMode
);In the logs below, you can see that push is in AUTOMATIC mode and two changes are sent to the client via PUSH, but then the block in viewModel?.getCounterValueList()?.collectLatest { }
gets not invoked anymore.
2024-07-02 14:21:56,102 DEBUG [com.vaa.flo.ser.com.PushHandler] (vert.x-eventloop-thread-1) New push connection for resource 04c339a6-be20-4537-86b8-5c58bc4a77dd with transport WEBSOCKET
2024-07-02 14:21:56,137 ERROR [io.vaa.iss.pag.hom.HomePage] (executor-thread-1) pushMode -> DISABLED
2024-07-02 14:21:56,138 ERROR [io.vaa.iss.pag.hom.HomePage] (executor-thread-1) pushMode UI -> AUTOMATIC
2024-07-02 14:21:56,170 ERROR [io.vaa.iss.pag.hom.HomePage] (executor-thread-1) getCounterValueList / newestValue -> null
2024-07-02 14:21:56,171 ERROR [io.vaa.iss.pag.hom.HomePage] (executor-thread-1) getCounterValueList / counterSpan.text ->
2024-07-02 14:21:56,179 DEBUG [com.vaa.flo.ser.com.UidlWriter] (executor-thread-1) * Creating response to client
2024-07-02 14:21:56,201 DEBUG [com.vaa.flo.ser.com.PushHandler] (vert.x-eventloop-thread-1) Received message from resource 04c339a6-be20-4537-86b8-5c58bc4a77dd
2024-07-02 14:21:56,204 DEBUG [com.vaa.flo.ser.com.UidlWriter] (vert.x-eventloop-thread-1) * Creating response to client
2024-07-02 14:21:57,157 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 0
2024-07-02 14:21:57,165 ERROR [io.vaa.iss.pag.hom.HomePage] (DefaultDispatcher-worker-1) getCounterValueList / newestValue -> 0
2024-07-02 14:21:57,165 ERROR [io.vaa.iss.pag.hom.HomePage] (DefaultDispatcher-worker-1) getCounterValueList / counterSpan.text -> 0
2024-07-02 14:21:57,166 DEBUG [com.vaa.flo.ser.com.UidlWriter] (DefaultDispatcher-worker-1) * Creating response to client
2024-07-02 14:21:58,167 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 1
2024-07-02 14:21:59,169 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 2
2024-07-02 14:22:00,170 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 3
2024-07-02 14:22:01,171 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 4
2024-07-02 14:22:02,172 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 5
2024-07-02 14:22:03,174 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 6
2024-07-02 14:22:04,175 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 7
2024-07-02 14:22:05,175 ERROR [io.vaa.iss.pag.hom.HomePageViewModel] (DefaultDispatcher-worker-1) counterValueList / repeat -> 8
...
Given that, it looks like to me that the problem is not PUSH, but the callback not being invoked on changes applied to getCounterValueList()
.
Also, clicking the "CLICK to receive all push UI changes" button has no effects. I cannot see any updates to the UI because there a no pending changes.
Maybe @mvysny can provide some advice here
@mcollovati ok I will look into it. Then why there is this error message when ssl is enabled ?
Can you please provide the steps to run your application with SSL enabled?
Ok, I managed to start the application with SSL. What I can see is that with SSL enabled, the push script is downloaded as a binary file instead of a JavaScript resource.
The culprit seems to be this setting quarkus.http.enable-compression=true
in application.properties
If I remove it, the Vaadin PUSH script is downloaded correctly and there is no error message.
@mcollovati ok so how to use compression if using it crashes push ?
Push script is added with a standard <script>
tag, so I don't know why it is not working with compression. Other javascript resources are working fine (e.g. index-xxxxx.js).
I wonder if it is something specific to Quarkus and SSL.
@mcollovati so it seems I did found a bug ๐
I wonder if it is a problem of double compression. Flow already provides compressed version of several resources. Maybe Quarkus does not detect that the resource is already compressed and it does an additional compression. It can be tested by downloading vaadinPush.js
It might be this way. I cant test this - javascript is something I am not familiar with
I can confirm that the vaadinPush.js is compressed twice. It looks like a Quarkus issue
Hmm so now I should be waiting for a fix ? ๐ @mcollovati I am very grateful for your help with this ๐
@mcollovati so I checked everything and it seems that disabling compression helps bu still the UI is not getting updated ๐ข
Unfortunately, I cannot help with Kotlin, but I tried to add the following to the HomePage.onAttach(...)
method and I can see the UI updated every second
val service = Executors.newScheduledThreadPool(1)
val ui = attachEvent!!.ui
service.scheduleAtFixedRate({
ui.access {
counterSpan.text = LocalTime.now().toString()
}
}, 1, 1 , TimeUnit.SECONDS)
So, I suppose that there might be some issue in your code that prevents viewModel?.getCounterValueList()?collectLatest()
callback being executed.
I hope @mvysny could take a look at your code and provide some suggestion.
@mvysny I did mamy project using vaadin + spring boot and with this combination the same kotlin StateFlow with collect() or collectLatest() works. It does not work with vaadin + quarkus combination
@JasonTheDynamite regarding Kotlin Coroutines, it's very important to use the correct coroutine dispatcher which calls ui.access(). Please see https://github.com/mvysny/vaadin-coroutines-demo for an example.
Describe the bug
I am getting this error on the frontend using vaadin with quarkus: https://192.168.1.100/VAADIN/static/push/vaadinPush.js could not be loaded. Push will not work. Looks like this: Push does not work at all.
Logs show this: io.package.website.configuration.VaadinAppShell' is not a CDI bean. Falling back to default instantiation.
Currently push works only when there is a user interaction with the frontend - for example a usern needs to click a button to force changes to the frontend.
Gradle properties
quarkusPluginId=io.quarkus quarkusPluginVersion=3.12.0 quarkusPlatformGroupId=io.quarkus.platform quarkusPlatformArtifactId=quarkus-bom quarkusPlatformVersion=3.12.0 vaadinVersion=24.4.4 vaadinPluginVersion=24.4.4 kotlinVersion=2.0.0
build.gradle: `plugins { id "java" id "application" id 'org.jetbrains.kotlin.jvm' version "${kotlinVersion}" id 'org.jetbrains.kotlin.kapt' version "${kotlinVersion}" id "org.jetbrains.kotlin.plugin.allopen" version "${kotlinVersion}" id 'org.jetbrains.kotlin.plugin.jpa' version "${kotlinVersion}" id 'com.github.gmazzo.buildconfig' version '5.3.5' id "com.vaadin" version "${vaadinPluginVersion}" id 'io.quarkus' }
apply plugin: 'kotlin'
repositories { mavenCentral() maven { url = uri("https://plugins.gradle.org/m2/") } maven { url "https://maven.vaadin.com/vaadin-addons" } google() gradlePluginPortal() }
dependencies { implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
// implementation "com.vaadin:vaadin-core:${vaadinVersion}" implementation "com.vaadin:vaadin-quarkus-extension:${vaadinVersion}"
}
def props = new Properties() props.load(new FileInputStream(new File("src/main/resources/application.properties")))
group 'io.package' version '1.0.0-SNAPSHOT'
java { sourceCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21 }
test { systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" } allOpen { annotation("jakarta.ws.rs.Path") annotation("jakarta.enterprise.context.ApplicationScoped") annotation("jakarta.persistence.Entity") annotation("io.quarkus.test.junit.QuarkusTest") }
compileKotlin { kotlinOptions.jvmTarget = JavaVersion.VERSION_21 kotlinOptions.javaParameters = true kotlinOptions { freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" freeCompilerArgs += "-opt-in=kotlinx.coroutines.ObsoleteCoroutinesApi" freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" freeCompilerArgs += "-opt-in=kotlin.ExperimentalStdlibApi" } }
compileTestKotlin { kotlinOptions.jvmTarget = JavaVersion.VERSION_21 kotlinOptions.javaParameters = true kotlinOptions { freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi" freeCompilerArgs += "-opt-in=kotlinx.coroutines.ObsoleteCoroutinesApi" freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn" freeCompilerArgs += "-opt-in=kotlin.ExperimentalStdlibApi" } }
application { mainClass.set("io.minifyimage.website.App") }
jar { zip64 = true exclude 'META-INF/.RSA', 'META-INF/.SF', 'META-INF/*.DSA' duplicatesStrategy(DuplicatesStrategy.EXCLUDE) from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
} `
Expected behavior
Push should work.
Actual behavior
Push does not work which means that the website contents does not change.
How to Reproduce?
Steps:
Output of
uname -a
orver
Darwin MacBook-Air.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64
Output of
java -version
OpenJDK Runtime Environment Zulu22.30+13-CA (build 22.0.1+8) OpenJDK 64-Bit Server VM Zulu22.30+13-CA (build 22.0.1+8, mixed mode, sharing)
Quarkus version or git rev
3.12.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)8.7
Additional information
No response
Expected-behavior
Push should work.
Reproduction
Steps:
System Info
Darwin MacBook-Air.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64
OpenJDK Runtime Environment Zulu22.30+13-CA (build 22.0.1+8) OpenJDK 64-Bit Server VM Zulu22.30+13-CA (build 22.0.1+8, mixed mode, sharing)
Quarkus version: 3.12.0
Gradle wrapper: 8.7