When dealing with long-held connections, one of the most frequently encountered problems is that, by default, most browsers drastically limit the number of concurrent connections. Internet Explorer, still the most-used web browser, limits to 2 connections (Firefox, for comparison, defaults to 6). This creates a problem with long-held requests, because the long-held connection will interfere with other, standard requests.
Thankfully, there's a pretty simple solution: place your streaming connections on a subdomain. Since all browsers treat subdomains as a unique domain for the purposes of limiting concurrency, you can move your streaming connections to a subdomain (or multiple subdomains; wildcard DNS is a great option here) and be off to the races. The downside is that this solution requires that your JavaScript client is capable of cross-domain communication. But good news - the WebSync JavaScript supports cross-domain communication out of the box!
Let's look at an example:
// random character (a-z)
var c = String.fromCharCode(Math.floor(Math.random()*25+97));
fm.websync.client.initialize({
requestUrl: 'http://www.foo.com/request.ashx',
stream: {
requestUrl: 'http://' + c + '.stream.foo.com/request.ashx'
}
});
This example places our "normal" requests (such as publishes/subscribes/etc) on the root domain, and the "stream" requests (all the long-held stuff) on a random subdomain under "stream.foo.com". When the page loads, we'll grab a random domain, so until a given user loads up at least 3 pages, all at the same time, that all randomly get the exact same character, the long-held connections won't interfere.
If you wanted to make this even more bullet proof, simply replace the single character 'c' with a multiple-character subdomain. Since we're using wildcard DNS, it doesn't really matter what the characters are, just that they're unique for the given client.