Hearbeat seems to be not working in Vaadin 7.1.16

I created a detach listener and I added it to my UI.
The heartbeat interval parameter is set to 60 and then I thought the detach method would be called after 3 minutes after I cloded the browser.
I doesn’t happen.
The method is called after 30 minutes at the session timeout.
What’s wrong ?

I think there is nothing wrong. This works as coded.

The last UI is detached at session timeout (provided that closeIdleSessions is set to true) and the additional UIs (browser tabs) fire detached event after three heart beats.

Tks for Your answer but how to free resources when the browser is closed in a reasonable time without waiting session timeout ?

Btw, are you really using 7.1.16, not 7.7.16. I would strongly recommend to upgrade to newest available version.

Apart from that you have basically two alternatives, either use this add-on


Or set session timeout to be shorter.

Sorry I was wrong I’m using 7.7.16.
I already tested the addon but again it seems to wait the session timeout.
Do you have any suggestion about the usage ?
If I set a shorter session timeout what happens in the “normal” usage, if the user wait more than the timeout before answering ?

I already tested the addon but again it seems to wait the session timeout

Did you check the demo app source code of the CleanupServlet


Idea of the add-on is that VaadinServlet is replaced by CleanupServlet in your app (which is extended VaadinServlet)

And it is configured by overriding the getters.

If I set a shorter session timeout what happens in the “normal” usage

In many application containers 30min is the default. However that does not mean that it is optimal for all apps. Apps differ by how they are being used. E.g. if you have lot of users that just come and peek couple of things in the app and then go away, there will be lot of user churn. If the app is like this, the session timeout should be set as short as possible. This way more users can be served with same amount of server resources. On the other hand in some apps the users have longer sessions, like dashboard apps used for monitoring processes. Then longer session timeout is more appropriate.