Skip navigation.

Multi-frame Handling

cometd-jetty Multi-frame Handling

The recommended HTTP connection limit of 2 connections per host is per browser. Thus any iframes, tabs or windows on the same browser connecting to the same host need to share the two connections.

If two frames/tabs/windows initiate cometd, both will start a long poll connect request and both connections will be consumed.

The Jetty cometd implementation implements 3.6.5 multiple-clients advice. The server uses "BAYEUX_BROWSER" cookie set on the browser to detect multiple clientIDs from the same browser.

If multiple clients are detected, any /meta/connect requests in excess of 1 will not wait for any messages before returning. They will return immediately with the "multiple-clients" field of the advice object set to true. The advice will also contain an "interval" field set to the value of the "multiFrameInterval" servlet init parameter. This instructs the client not to send another /meta/connect until that number of milliseconds has passed.

Thus the effect of this advice, is that additional client connections will poll the server with a period of "multiFrameInterval" milliseconds. The first /meta/connect will long poll as normal. This avoids consume both HTTP connections at the cost of some latency for the additional frames/tabs/windows.

It is recommended that the client application also monitor the /cometd/meta topic for multiple-clients advice. If detected, the application may ask the user to close the additional tabs, or it could automatically close or take some other action.