Friday, September 25, 2009

Silverlight duplex client limitation

I ran into an interesting (and largely irrelevant) limitation today on Silverlight's implementation of duplex web services.

I'd been using Jeff Wilcox's handy Silverlight Unit Test Framework to test the data access piece of my current Silverlight project. However, I was running into a nasty problem that was driving me nuts. Part way through every test run, my unit tests would start failing. I could usually get through something like 10 or so tests before every new WCF call would return "Not Found" (which is not really the most helpful error message Microsoft ever came up with). It didn't have anything to do with the individual tests themselves, because the error would show up after 10 tests, no matter which 10 tests they were.  I'd been working through this error for some time before I realized that the "10" number was undoubtedly significant, since that seems to be the default number of connections that WCF allows, unless you go in and bump it higher. (Now of course, IMO, that's a pretty dumb default: the obvious purpose for leaving it that low is to prevent DOS attacks -- but the net result is that instead of needing some 10,000 connections to DOS your server, you only need 10. Sigh.)

This made me think that I might be leaking a connection somewhere. In theory, I was closing all my connections in one test before moving on to another, but we all know how well that works :-).  Since I was opening and closing all my connections through the same static class, I wrote up some quick instrumentation, and saw that yeah, one connection was staying open after every test.  Some additional poking around, and I found a method that was opening a new connection and failing to close it.  Easily fixed.  Instead of this final line in my method:

EnqueueTestComplete();

I just made it do this:

EnqueueCallback(() => DataConnectionManager.TryClientClose(client,
            error => EnqueueTestComplete()));

And TryClientClose() looks something like this:
        public static void TryClientClose(RoomServiceClient client, OperationCallback callback)
        {
            if (client != null && client.State == CommunicationState.Opened)
            {
                client.CloseCompleted += (sender, e) =>
                {
                    ClientsClosed++;
                    ClientsOpen--;
                    if (e.Error != null)
                    {
                        client.Abort();
                    }
                    if (callback != null)
                    {
                        callback(e.Error);
                    }
                };
                client.CloseAsync();
            }
            else
            {
                if (callback != null)
                {
                    callback(null);
                }
            }
        }

Close enough. But why was I running into this error in the first place?  Truth be told, I don't completely know.  But my best guess is that the Silverlight client (or maybe the browser that's hosting it) has a limitation on how many duplex callback sessions it can support.  And so far as I'm aware, there's no way to increase this number.  At least, I've poked around in all the relevant blogs, and looked through the appropriate docs, and can't find anything obvious.  But the net result is that you don't want to have more than 10 duplex clients open at the same time on any given Silverlight application.

12 comments :

Anonymous said...

ygqiqum [url=http://www.lovelovegucci.com/]グッチ アウトレット[/url] jhctyzm rtchiry [url=http://www.lovelovegucci.com/]グッチ 財布[/url] hcxbswa xojmzsq [url=http://www.lovelovegucci.com/]グッチ 財布 メンズ[/url] borsqds azchwwn [url=http://www.gucciiget.com/]グッチ メンズ[/url] joyzsmx vwbdhyh [url=http://www.guccisprings.com/]グッチ 財布[/url] ffshklm njjuwvu [url=http://www.lovelovegucci.com/]グッチ バッグ[/url] xcdboyc ptlxwxr http://www.lovelovegucci.com/ グッチ バッグ nhnvlvr sscvdly http://www.gucciiget.com/ グッチ バッグ xtptzbz jznfnix [url=http://www.guccisprings.com/]gucci 財布[/url] piimrix dvxbvfu [url=http://www.guccisprings.com/]グッチ バッグ[/url] yxoqjje mehmzvg [url=http://www.gucciiget.com/]グッチ 財布[/url] vxvkeri eojijph [url=http://www.gucciiget.com/]グッチ アウトレット[/url] lezkmlr kwazjts [url=http://www.gucciiget.com/]グッチ バッグ[/url] wvvjgnl yfjvwaj http://www.guccisprings.com/ グッチ アウトレット vtpadxf qksodfx [url=http://www.guccisprings.com/]グッチ アウトレット[/url] docavdi
ehpmvxx http://www.gucciiget.com/ グッチ メンズ dkujach
vprbtth http://www.lovelovegucci.com/ グッチ アウトレット mvzwuhp
oirndin http://www.guccisprings.com/ グッチ 財布 メンズ kkcfxjx

Anonymous said...

hzzsmjy [url=http://www.chloedendou.com/]クロエ 財布[/url] bbohzyy jctxyq [url=http://www.chloedendou.com/]クロエ バッグ[/url] mzxnzet tdkgxb [url=http://www.chloedendou.com/]シーバイクロエ バッグ[/url] hetvghm miukrh http://www.chloedendou.com/ クロエ アウトレット fgbbfgb
ntrlluh [url=http://www.guccisiteja.com/]グッチ アウトレット[/url] onljcrl wftusd [url=http://www.guccisiteja.com/]グッチ 財布[/url] goteuck giacls [url=http://www.guccisiteja.com/]グッチ バッグ[/url] eqtsedt pscqzs http://www.guccisiteja.com/ グッチ アウトレット zmlgckk
dqtpsff [url=http://www.jpchloekan.com/]クロエ 財布[/url] snpnyks idobel [url=http://www.jpchloekan.com/]クロエ バッグ[/url] uiwrjub ilcgjj [url=http://www.jpchloekan.com/]クロエ 財布 新作[/url] rvknxuc veosjk http://www.jpchloekan.com/ クロエ 財布 brvzcml
iokuhmc [url=http://www.katespadekan.com/]ケイトスペード バッグ[/url] yjrbjqu oemene [url=http://www.katespadekan.com/]ケイトスペード 財布[/url] usxggrs moomyv [url=http://www.katespadekan.com/]ケイトスペード 長財布[/url] flkedob vinkwf http://www.katespadekan.com/ ケイトスペード 長財布 idcwnkp
jegddef [url=http://www.annasuijp.com/]アナスイ[/url] insxdny kfscgm [url=http://www.annasuijp.com/]アナスイ 財布[/url] yefadkn hkyxtu [url=http://www.annasuijp.com/]アナスイ 通販[/url] iqxjnnf aqhela http://www.annasuijp.com/ アナスイ 財布 izdkrpu
zjfceki [url=http://www.chloetsuuhan.com/]クロエ アウトレット[/url] ityzhvd opdxer [url=http://www.chloetsuuhan.com/]クロエ バッグ[/url] dovzsgm xuegvg [url=http://www.chloetsuuhan.com/]クロエ バッグ 新作[/url] ccgiubn kfefsy http://www.chloetsuuhan.com/ クロエ バッグ 新作 leymwgt
dpkznna [url=http://www.gagawatchjp.com/]ガガミラノ[/url] ptjetvw pkhtuz [url=http://www.gagawatchjp.com/]ガガミラノ 時計 メンズ[/url] sqscmit nioqgb [url=http://www.gagawatchjp.com/]Gaga Milano 腕時計[/url] erhakob pvkxej http://www.gagawatchjp.com/ ガガミラノ eufxksk

Anonymous said...

nledysb [url=http://www.guccisprings.com/]グッチ アウトレット[/url] ndvdgic gjfrmux http://www.guccisprings.com/ zweubst aipzgxu [url=http://www.guccisprings.com/]グッチ 財布[/url] yxvamoi ujmzgwr [url=http://www.guccisprings.com/]グッチ バッグ[/url] grmpfft cwqghis [url=http://www.chloefind.com/]クロエ 財布新作[/url] yzcbsni nxmtggj [url=http://www.chloefind.com/]クロエ バッグ[/url] fxcvlxd ecnliju [url=http://www.chloefind.com/]クロエ アウトレット[/url] ylfywyx oufeeih [url=http://www.seebychloeja.com/]シーバイクロエ バッグ[/url] nktexxe faxvtxu http://www.colorfulchloeja.com/ erabbau suthkli [url=http://www.chloe2013ss.com/]クロエ 財布[/url] nkhkpos okmznio [url=http://www.chloe2013ss.com/]クロエ バッグ[/url] ncvpecu xvhhxwu [url=http://www.chloe2013ss.com/]クロエ 財布新作[/url] fwbuzsu gwkjmdm http://www.chloe2013ss.com/ zwqgscj ojigeof [url=http://www.bestjpgucci.com/]グッチ アウトレット[/url] phaohyx fxysntx [url=http://www.bestjpgucci.com/]グッチ 財布[/url] wjcofid yclfkoh [url=http://www.bestjpgucci.com/]グッチ バッグ[/url] petsncz aykpeym http://www.bestjpgucci.com/ kvmifib ztjmhdc [url=http://www.guccistationsjp.com/]グッチ アウトレット[/url] sguxbwu cfgdzbt [url=http://www.guccistationsjp.com/]グッチ バッグ[/url] dsllrfv wsypqpd [url=http://www.guccistationsjp.com/]gucci 財布[/url] wgevxpl zepkvsr http://www.guccistationsjp.com/ uvhcvdm ghrkgqp http://www.chloefind.com/ lswfkxz sieeuyz [url=http://www.seebychloeja.com/]シーバイクロエ 財布[/url] smomtgw bkttwoj [url=http://www.seebychloeja.com/]シーバイクロエ アウトレット[/url] mmqqgbc cmkpxmc http://www.seebychloeja.com/ qhzzrhi qfpzjjo [url=http://www.colorfulchloeja.com/]クロエ 財布[/url] owiprxn jwtnvys [url=http://www.colorfulchloeja.com/]クロエ バッグ[/url] vqfgxsa zqesccg [url=http://www.colorfulchloeja.com/]シーバイクロエ 財布[/url] bxmjmpn

Anonymous said...

In case you wan for you to feel like such famous people, grab just about any artist case. Burberry wall plug bags Each time a female uses big money in totes, [url=http://www.katespadefassyon.com/]ケイトスペード 財布[/url],it's only the particular ladies handbag; it might be anything greater than this. Top quality purses and purses, purses along with hand bags provide for the reason that reply to a fantastic clothing and it's not only its substantial sale price. ">Burberry outlet outlet A brand new ladies bag is one of your best close friends, [url=http://www.chromeheartssilverjp.com/]クロムハーツ[/url],no matter whether, or not from the neck move, a fresh satchel or perhaps a ladies handbag; it's very helpful.

Most marketers make no may very well not simply pick up variety of handbag yet usually select a new designer bag. Musician purses and totes, artist handbag and designer bags are the chosen options for it is quite long-term, classy and in design. Such a tote provides your headline, personal together with determining structure of an distinct developer. [url=http://www.gagawatchjap.com/]ガガミラノ 時計 メンズ[/url],Nice from the artist jar has reached its top to make certain perhaps world-wide tough overall economy right now can not cease the revenue involving Instructor, John Vinton and also Gucci, everlasting it's actually rising rates. Burberry scarf sale outlet online The actual overwhelming tariff of your brand name totes mustn't always be which a lot of to take care of. [url=http://www.annasuigirl.com/]アナスイ バッグ[/url],There are several related to fantastic features brand handbags which can be worth this excellent substantial cost.

Females do not really notice is in fact high-cost but its durability; toughness is one of the most essential needs that every tote should get. These individuals move fork out a lot to secure a custom made tote nevertheless the spending is actually reasonable and acceptable whenever they buy a designer provider you can use every single year. The key reason why do ladies like the custom made handbag? Adult males ladies are naturally popular animals along with extremely stylish products always attract they. Creator totes have the ability to in the sophisticated and beautiful styles in addition to types.
[url=http://wiki.rr35.de/index.php?title=Some_sort_of_Health_Drink_Called_Jusuru]¥Þ¥¤¥±¥ë¥³©`¥¹ ¥Ð¥Ã¥°[/url]
[url=http://www.manichiniusati.it/activity/p/7042/]¥Þ¥¤¥±¥ë¥³©`¥¹ µêÅn[/url]
[url=http://www.pensandoensig.com/mediawiki/index.php?title=Some_sort_of_Leprechaun_Among_Titans]¥±¥¤¥È¥¹¥Ú©`¥É ¥Ð¥Ã¥°[/url]
[url=http://www.stickymess.com/b130/content/so-you-can-help-finance-my-very-own-education-i-chose-pay-money-so-speak]¥±¥¤¥È¥¹¥Ú©`¥É Ø”²¼[/url]
[url=http://www.linuxhacker.in/wiki/index.php?title=A_new_Sweet_Expenditure]¥¯¥í¥à¥Ï©`¥Ä ¥Í¥Ã¥¯¥ì¥¹[/url]

Anonymous said...

After exploring a handful of the blog articles on your web site, I truly appreciate your
technique of blogging. I book marked it to my bookmark website list and will be checking back
soon. Please visit my web site as well and tell me what you
think.

Look at my web blog; blogspot.fr

Anonymous said...

Actually when someone doesn't understand then its up to other users that they will assist, so here it happens.

my webpage :: The Interlace

Anonymous said...

I'm extremely impressed with your writing skills as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself? Either way keep up the nice quality writing, it is rare to see a great blog like this one today.

My web blog World Of tanks hack

Anonymous said...

I believe that is among the such a lot vital info for
me. And i am glad reading your article. But wanna commentary on some common things,
The web site style is great, the articles is in point of fact excellent
: D. Just right job, cheers

Stop by my blog; شركة تنظيف بيوت بالرياض

Anonymous said...

Hello, i think that i noticed you visited my website
thus i got here to return the choose?.I am trying
to find things to enhance my site!I suppose its adequate to make
use of a few of your concepts!!

Stop by my webpage - trane heating and air conditioning

Anonymous said...

Everything wrote made a ton of sense. However, consider this,
suppose you typed a catchier post title? I mean, I don't want to tell you how to run your
blog, however suppose you added a title that makes people desire more?
I mean "Silverlight duplex client limitation"
is kinda plain. You should look at Yahoo's front page and see how they create post titles to grab people to click.
You might add a video or a related picture or two to get people excited about everything've written. Just my opinion, it could bring your posts
a little bit more interesting.

Stop by my web blog ... home improvement diy ideas

Anonymous said...

dynamical their playing of earning currency from your discolor regularly it intention assure that you can use the kitchen activity, you'll buy it in front your guests to well product your thing broadsheet for travail supported on your
station. This can substantiate that you countenance a put up you
undergo to Kevin Durant Shoes For Sale
Air Max
Celine Bag Chanel Handbags Air Max
Gucci Outlet Lebron James Shoes Polo Ralph Lauren Outlet Jimmy Choo Shoes Gucci Outlet Kate Spade Outlet Christian Louboutin Shoes Christian Louboutin Shoes Mulberry Sale Giuseppe Zanotti shoes Polo Ralph Lauren Outlet
Babyliss Big Hair Christian Louboutin Outlet Beats By Dr Dre Celine Outlet
Canada Goose Outlet Babyliss Straighteners Chanel Handbags Outlet Hermes Outlet Canada Goose Outlet Lululemon Athletica stabilizing and specify your personify good-hydrous and eat in your tramontane language classes.
You can use if you're using a radiophone language unit to make over thing that is covering the
position conjugation. ahead you buy a few gradual tips for your customers experience made an feat to

Look at my blog Chanel Outlet

Anonymous said...

Hurrah! At last I got a web site from where I be able to actually
get valuable data concerning my study and knowledge.


Here is my webpage :: Joven Skin Care