My question is regarding how Bayeux protocol is making it possible to have multiple tabs opened in a single browser. If we use publish/subscribe paradigm also, we need to send request to server for subscribing then will that connection be opened? If opened then how is it preventing the connection limit. If the connection is not opened then how does the server send the data to multiple tabs.
2 Answers
The HTTP standard connection limit is recommended to be 2, but that is only a recommendation. No modern browsers actually impose a 2 connection limit anymore.
However, to address this the Bayeux protocol also recommends that applications use cookies to detect when multiple tabs are open and prompt the user to close all but one.
http://svn.cometd.com/trunk/bayeux/bayeux.html
It is RECOMMENDED that Bayeux client implementations use client side persistence or cookies to detect multiple intances of Bayeux clients running within the same HTTP client. Once detected, the user MAY be offered the option to disconnect all but one of the clients. It MAY be possible for client implementations to use client side persistence to share a Bayeux client instance.

- 1
- 1

- 73,278
- 17
- 138
- 182
-
Thanks Samuel for your reply. But, if a single user opens same instance on all tabs, I want realtime notifications to be received in all the tabs opened. You mentioned that user may be offered to disconnect all but one of the clients. Then, in this case, will all the tabs get realtime notifications? Is it possible if client side peristance share a Bayeux client instance. Is there any example of this scenario? – cherry Aug 01 '12 at 17:18
-
For a more general perspective, you might want to check out this: http://stackoverflow.com/questions/9554896/sharing-websocket-across-browser-tabs – Alessandro Alinone Aug 01 '12 at 18:32
-
@cherry, the example is talking about the now rare case where the browser restricts each server to two simultaneous connections. Another option for communication between tabs is to use Flash. Every Flash instance can talk to the others that were served by the same server via something called `LocalConnection`. This is done entirely client-side, no server involved. They can talk to Javascript via `ExternalInterface` so one could create a generic tab communication project using Flash as the go-between. – Samuel Neff Aug 02 '12 at 01:14
-
Hi Samuel : I am having some issue with Cometd, maybe you can provide some insight into this problem : http://stackoverflow.com/questions/36334314/android-cometd-cometd-sending-alternate-messages . Thanks a lot. :-= – We are Borg Apr 08 '16 at 09:28
The updated Bayeux specification is at http://docs.cometd.org/reference/#bayeux.
The handling of multiple clients from the same browser is discussed in the CometD reference at http://docs.cometd.org/reference/#java_server_multiple_sessions.

- 16,856
- 1
- 50
- 45
-
Thanks for sharing the documents. It is mentioned that only one long poll request is allowed when multiple tabs are opened. Then, is it possible that all the tabs receive real time notifications? – cherry Aug 01 '12 at 17:23
-
In CometD you can configure the number of active long-polls using the
maxConnections
parameter in the client, and themaxSessionsPerBrowser
parameter in the server. If you set those to reasonable numbers such as 2 or 3, you may have that number of tabs receiving "real-time" notifications. Additional tabs are polling normally, and therefore have a max latency that is equal to themultiSessionInterval
, by default 2 seconds. – sbordet Aug 08 '12 at 10:02