Handling comet disconnection on page unload/reload

27 views
Skip to first unread message

Cosimo

unread,
Jun 16, 2020, 5:28:56 AM6/16/20
to cometd...@googlegroups.com
Hi,

we're experiencing a problem dealing with comet sessions when a user reloads the application page.

We identify users by a key value. When a user reloads the web page, an onBeforeUnload handler disconnects the comet session. When the page then loads up again, a new comet session is established with the same user key value. Server-side, before handing control of the user to the new comet session, we check that there's no previously active session (for the same user key) still connected.

On some browsers, the onBeforeUnload handler does not fire properly or completely (namely, Firefox),
so the corresponding comet session results still active when the new one tries to take control.

I was wondering if anyone using comet has had to deal with this problem and how they've done that.

Cheers,

--
Cosimo

Simone Bordet

unread,
Jun 16, 2020, 5:41:34 AM6/16/20
to cometd-users
Hi,
According to https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload,
the event is supported since the dawn of browsers.

Note that it is all lowercase.

The CometD vanilla examples use window.onunload.

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
Reply all
Reply to author
Forward
0 new messages