javavaadinsession-timeout

Session timeout is immediately followed with a page reload, starting a new session


When the VaadinSession timeout happens, the page automatically reloads starting a new VaadinSession.

Vaadin 23.0.5

Below, I have included the Chrome console log as the session ends and the reload happens. There is nothing indicating why this is going on in the java logs. This appears (to me) to be initiated in the browser, possibly by the service worker?

Suggestions for further diagnostics, or just an outright solution (I can dream) would be greatly appreciated.

Here is the Chrome console as the Session terminates...

Received push (websocket) message: for(;;);[{"syncId":4,"clientId":2,"meta":{"async":true,"sessionExpired":true},"timings":[5,0]}]
FlowClient.js?2d7e:1004 Handling message from server
FlowClient.js?2d7e:944 Handling dependencies
FlowClient.js?2d7e:193 handleUIDLMessage: 0 ms
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: beforeunload event
FlowClient.js?2d7e:193 Setting heartbeat interval to -1sec.
FlowClient.js?2d7e:835 Disabling heartbeat
FlowClient.js?2d7e:936 Closing push connection
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Closing (AtmosphereRequest._close() called)
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Firing onClose (unsubscribe case)
FlowClient.js?2d7e:1006 Push connection closed
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (unsubscribe case)
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: invoking .close() on WebSocket object
FlowClient.js?2d7e:193  Processing time was 5ms
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (unsubscribe case)
logger.js?aa4d:46 workbox No route found for: /?v-r=push&v-uiId=0&v-pushId=09139213-af19-48d7-8a55-278da41b839f&X-Atmosphere-Transport=close&X-Atmosphere-tracking-id=3c2a0c76-86d7-4952-a1c4-80786dd19bd0
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: websocket.onclose
vaadinPush.js?v=23.0.4:3323 Websocket closed, reason: Normal closure; the connection successfully completed whatever purpose for which it was created. - wasClean: true
log @ vaadinPush.js?v=23.0.4:3323
warn @ vaadinPush.js?v=23.0.4:3329
_websocket.onclose @ vaadinPush.js?v=23.0.4:1537
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (closed case)
vaadinPush.js?v=23.0.4:3323 Mon Jun 06 2022 13:41:09 GMT+1000 (Australian Eastern Standard Time) Atmosphere: Request already closed, not firing onClose (closed case)
vaadinPush.js?v=23.0.4:3323 Websocket closed normally

Which is immediately followed with the page reloading...

logger.js?aa4d:46 workbox The navigation route / is being used.
logger.js?aa4d:46 workbox Router is responding to: /
logger.js?aa4d:46 workbox Network request for '/' returned a response with status '200'.
logger.js?aa4d:46 workbox Using NetworkOnly to respond to '/'
ā€‹ Mon Jun 06 2022 13:41:11 GMT+1000 (Australian Eastern Standard Time) Atmosphere: unload event
logger.js?aa4d:46 workbox No route found for: 
https://api.breadbutter.io/apps/xxxxxxxxxxxxxxxx/prerelease/page_engagement
logger.js?aa4d:46 workbox Router is responding to: /VAADIN/build/vaadin-bundle-52a045587b10cc017547.cache.js
logger.js?aa4d:46 workbox Found a cached response in 'workbox-precache-v2-https://mylocalhost/'.
logger.js?aa4d:46 workbox Precaching did not find a match for /?v-r=init&location=
logger.js?aa4d:46 workbox No route found for: /?v-r=init&location=
logger.js?aa4d:46 

Solution

  • Yes, this is intended behavior.

    You need to setup servlet initialized listener and there define customized system messages, there sessionExpiredURL needs to be not null (null is the default value, and if it is null, page will reload upon session expired)

           getService()
                    .setSystemMessagesProvider(new SystemMessagesProvider() {
                        @Override
                        public SystemMessages getSystemMessages(
                                SystemMessagesInfo systemMessagesInfo) {
                            CustomizedSystemMessages messages = new CustomizedSystemMessages();
                            messages.setSessionExpiredNotificationEnabled(
                                    false); // or true
                            messages.setSessionExpiredURL( USE NON-NULL VALUE HERE );
                            return messages;
                        }
                    });