← Back to team overview

launchpad-dev team mailing list archive

Re: disabling longpoll

 

On Tue, 21 Feb 2012, Raphaël Badin wrote:

> > You don't need to ask the server anything. The server just has to
> > return an appropriate error code if there are too many connections.
> > The client can try again in several seconds. This is the simplest fix.
> > We already have a cookie that can be used to identify a browser at the
> > server end.
> 
> I'm not sure we want to have that "intelligent" longpoll logic on the
> server side (mostly for performance reason)…
> 
> > Or some other behavior. I could also imagine the server accepting the
> > new connection and disconnecting the oldest old. If the old client
> > tries reconnecting a few seconds later, we end up with round robin
> > longish polling.
> 
> Another solution would be to restrict longpoll usage to browsers which
> support HTML5's local storage and to have the client use it to store the
> number of long polling connections (localStorage['longpollconnections']
> = 4).  This way, the longpoll js code would simply stop creating long
> polling connections once the maximum number of connections (-1) is
> reached.  The only tricky part would be to make sure that the number of
> connections is properly decreased when tabs are closed.

This is certainly a possible way to do it. There's localStorage for nearly
all browsers (Older IE uses the name userdata I believe, but easily
wrapped). There are JS events for the unload of a page. YUI actually has
.on() whitelisted events for beforeunload and unload which could be used to
decrement the counters.

It's definitely something though that has potential to get off if say the
browser crashes or something. I wonder if there's a decent "reset" point to
clear the localStorage count, say on user login or something.

Since it's mostly internal, it'd be good to have some sort of indicator as
well, such as the Ajax log, that you could see the count and possibly
manually clear as issues were worked out.


-- 

Rick Harding

Launchpad Developer
https://launchpad.net/~rharding
@mitechie


Follow ups

References