Loading...
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
TUTORIAL

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

How to determine if UI was closed in browser?

András Lendvay
5 years ago Nov 04, 2016 10:37pm
Olli Tietäväinen
5 years ago Nov 07, 2016 6:52am

Hi,

I don't think browsers implement any reliable method of determining a close event. The UI is kept alive until it misses three consecutive Heartbeat requests; the default heartbeat is to be 5 minutes, so by that default it'll take up to 15 minutes to determine that the browser has closed. You can configure the heartbeat to be shorter with the heartBeatInterval param (see this wiki article), with obvious side-effects: if you set it to be too low, short network outages can also kill your session. 

-Olli

András Lendvay
5 years ago Nov 07, 2016 7:39am
Tatu Lund
5 years ago Nov 07, 2016 8:05am