I am beginner. I added vaadin-spring-boot-starter version 24.6.0 in my pom.xml file and wrote a java class that extends VerticalLayout. It adds a grid. It has a @Route annotation
When I start my application locally, it runs in development mode and fails with a message “Connection Lost” in the chrome browser tab.
I tried enabling production mode by adding vaadin.productionMode=true in application.properties file and running the build (with few more steps) but the outcome is the same.
Kindly suggest a fix for the “Connection Lost” error
I understand that vaadin uses websockets internally. How I configure to it use long polling and would there be any visible side effects apart from performance?
I think you have spring security in place without rules for Vaadin.
Compare your setup with a sample project from start.vaadin.com would be the saftest bet, otherwise it’s impossible to help without knowing you full setup
I tried comparing the sample project with mine and matching it but can’t figure out what could be causing the connection lost error. Nothing is displayed when navigating to the page mentioned in the @Route annotation.
I also checked through mvn dependency:tree -Dincludes=org.springframework.security command to see if our application had spring security dependencies and it turned out that spring security jars are getting added through the vaadin spring boot starter jar only. The output of the command is
When I enable com.vaadin debug logs I see the below error. I wonder why push is attempted when I don’t have any @Push annotation in my source code. Also the stack trace indicates that websockets are used.
Any expert inputs?
[http-nio-8080-exec-5] DEBUG c.v.f.s.communication.PushHandler - Session expired before push disconnect event was received
com.vaadin.flow.server.SessionExpiredException: null
at com.vaadin.flow.server.VaadinService.doFindOrCreateVaadinSession(VaadinService.java:985)
at com.vaadin.flow.server.VaadinService.findOrCreateVaadinSession(VaadinService.java:921)
at com.vaadin.flow.server.VaadinService.findVaadinSession(VaadinService.java:760)
at com.vaadin.flow.server.communication.PushHandler.handleConnectionLost(PushHandler.java:434)
at com.vaadin.flow.server.communication.PushHandler.connectionLost(PushHandler.java:388)
at com.vaadin.flow.server.communication.PushAtmosphereHandler.onStateChange(PushAtmosphereHandler.java:62)
at org.atmosphere.cpr.AsynchronousProcessor.invokeAtmosphereHandler(AsynchronousProcessor.java:538)
at org.atmosphere.cpr.AsynchronousProcessor.completeLifecycle(AsynchronousProcessor.java:480)
at org.atmosphere.cpr.AsynchronousProcessor.endRequest(AsynchronousProcessor.java:584)
at org.atmosphere.websocket.DefaultWebSocketProcessor.executeClose(DefaultWebSocketProcessor.java:689)
at org.atmosphere.websocket.DefaultWebSocketProcessor.close(DefaultWebSocketProcessor.java:635)
at org.atmosphere.container.JSR356Endpoint.onClose(JSR356Endpoint.java:318)
at org.apache.tomcat.websocket.WsSession.fireEndpointOnClose(WsSession.java:730)
at org.apache.tomcat.websocket.WsSession.onClose(WsSession.java:638)
at org.apache.tomcat.websocket.WsFrameBase.processDataControl(WsFrameBase.java:347)
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:279)
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:85)
at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:184)
at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:164)
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:152)
at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:60)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:57)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:904)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1741)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1190)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
at java.base/java.lang.Thread.run(Thread.java:833)
On troubleshooting further I could see the issue getting resolved if I add the vaadin.url-mapping property in my application.properties file.
The UI is now showing up.
Could someone explain how is this linked with the “Connection Lost” error I see in the browser and the websocket error stacktrace in the debug logs? @knoobie ?