How best to limit number of WebSocket connections?

Users of our app often have many browser tabs open at once - routinely 10-20 on average. Obviously, this will run afoul of the max 5 or max 10 WebSocket connections per user/app limit (I can never remember which is the accurate number, since the documentation lists both in different areas) for listening for Notifications.

I have been looking at using Web Workers to centralize a single WebSocket for our entire app, no matter then number of open tabs. I am running into issues such as Shared Workers do support XMLHttpRequest, but are not supported by all browsers and the GPC JS SDK doesn't really work in them due to root assignment logic of this vs. window (would be great if this were addressed!). And Service Workers are not really geared towards that type of usage (although it would be AWESOME if GPC supported Push API).

Is there a recommended method for ensuring a single WebSocket connection per user/browser?

Note that the limitation is on the number of notification channels, not the number of websockets. If make each page of your app reuse the existing notification channels created by the first instance, you should be fine.

Oh I get it! Thanks. :+1:

BTW, thanks for pointing that out. The correct number is 5. The API/SDK documentation will be updated shortly.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.