users@grizzly.java.net

Re: multiple tabs and onInterrupt behaviour

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Thu, 21 Jul 2011 10:59:34 +0200

Hi Eric,

> I set up a very simple test application where the servlet sends a
> message to all clients every 10 seconds and the clients simply keep
> track of how many times they have received a message.
> I tested it by opening the client on Chrome, Firefox and IE on a
> Windows 7 machine, as well as Firefox on a Linux machine. Both
> machines are on the same subnet. I found that if I opened it TWICE in
> Firefox, in two tabs, then only one tab would receive the update when
> the server pulsed. The tab that got the update would alternate. The
> same thing happened in chrome, but in IE both tabs would update
> together (as I'd have expected from the others). Why is this, and is
> there a way to fix it in Firefox and Chrome?
Not sure you can resolve it. IMO it's just a browser limitation. For
example I see the same behavior with gmail on FireFox, when new message
comes - one tab is getting updated, another not.

> In addition, I overrode onInterrupt() of CometHandler to send a
> message to all clients that would display a message saying that there
> was an interrupt, i.e. clients would know when some other client
> disconnected.
>
> It did not work as I expected. When I closed or refreshed the client
> pages in any browser on the windows machine, none of the others would
> receive the "interrupt occurred" message. However, if closed or
> refreshed in Firefox on the Linux machine, all three browsers on the
> Windows machine got the message. Also strange is that sometimes (but
> not always) they would get the message twice. Again, I'm trying to
> understand why...
Most probably when you close or refresh pages, some of the browsers
still keep the connection open in cache. You can check this using some
network tools like netstat.

> Finally, I was just wondering if this was the wrong place to ask
> beginner questions.
It's the right place :)


Thanks.

WBR,
Alexey.