Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Heartbeat not closing session

Andrea Posi
7 years ago Mar 02, 2016 2:11pm
Robert Carnecky
6 years ago Jun 23, 2016 4:43pm

IMO this is the biggest misunderstanding in the Vaadin framework, even the Book of Vaadin is missing one important point in the UI Closing mechanism description:

Heartbeat mechanism removes other UIs in the same session that are no longer active. The point is here in the same session!  There are scenarios, where the UI will close much later than 3*heartbeat interval, or even never:

  1. If you open a UI, then close it, and do nothing else with the application, it will live until the session expires (this is probably your 25/30 minutes). If your session timeout is set  to infinite like for monitoring applications, the UI (and your open resources) disappear never.
  2. If you open another UI and interact with it, the first UI is cleaned up only if the second UI belongs to the same session. Opening the second UI from another session/browser does not perform any cleanup!

Server-side there is no timer that periodically checks whether the last heartbeat of any UI was more than 3*N seconds ago. If you need to clear the resources or start a background task after the user closes the client, you have to do it in your code. Do not rely on heartbeat mechanism!