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:


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) =>
                    if (e.Error != null)
                    if (callback != null)
                if (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.


Anonymous said...

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

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=]ケイトスペード 財布[/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=]クロムハーツ[/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=]ガガミラノ 時計 メンズ[/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=]アナスイ バッグ[/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=]¥Þ¥¤¥±¥ë¥³©`¥¹ ¥Ð¥Ã¥°[/url]
[url=]¥Þ¥¤¥±¥ë¥³©`¥¹ µêÅn[/url]
[url=]¥±¥¤¥È¥¹¥Ú©`¥É ¥Ð¥Ã¥°[/url]
[url=]¥±¥¤¥È¥¹¥Ú©`¥É Ø”²¼[/url]
[url=]¥¯¥í¥à¥Ï©`¥Ä ¥Í¥Ã¥¯¥ì¥¹[/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

Look at my web blog;

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...

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