0

Here is the problem:

I have a Silverlight application where we would like to play 8 Silverlight MediaElements at once. All are playing .MP4 videos.

The first 6 will load almost immediately, and have the MediaOpened within a second or two. The remaining 2 will sometimes (not always) take minutes before playing / reporting that they are ready to play.

If I just play 6 or less, there seems to be no problem.

Here is what I've found:

1) There is no relation to the files. I can switch the order of the MediaElements and the first 6 I attempt to open will open just fine and the remaining will block.

2) There isn't necessarily a bandwidth issue (I tried compressing the files down to almost nothing and the same thing happened).

3) This isn't an IIS issue (my server), I don't think, since I've maxed out simultaneous connections.

4) My client machines are not pegged at all. The network is consistent at 25%, so it's possible the remaining 2 are being starved out there, but what's magic about the 7th and 8th?

Code

My code seems unimportant, but I will include it because people seem to like it when you do:

foreach ( String Uri in UriList )
{
   //For every URI we create a new MediaElement.  In our test case this is 8 always.
   MediaElement newMediaElement = new MediaElement();

   // We use MediaOpened as our 'ready to play' event.  Buffering remains at 0 for the 
   //  two streams that don't work.
   newMediaElement.MediaOpeened += new System.Windows.RoutedEventHandler(stream_MediaOpened);

   //Set the source and add it to some list to be added to a grid later...
   newMediaElement.Source = uri;       
   MediaElementList.Add( newMediaElement );
}

Following this the MediaElementList gets added to a Grid defined in XAML.

If people think more code will be helpful I'll add the specific parts. Like I said, I don't think the code will be useful, but you never know...

Other research

Other people have this problem, but we haven't found a solution. We've seen this and this and this, but none of them give any answer other than they don't know.

EDIT: Okay, so there's a limit of 6, as Kevev points out. Does anyone know of any way around this?

DanTheMan
  • 3,277
  • 2
  • 21
  • 40
  • Are you using IE8? Could it be that the maximum number of connections allowed by the browser has been reached? IE8 allows 6 connections. http://weblogs.asp.net/mschwarz/archive/2008/07/21/internet-explorer-8-and-maximum-concurrent-connections.aspx – kevev22 Sep 21 '11 at 20:57
  • No, this happens in Chrome and Firefox, too. Silverlight luckily gets around any limit of connections. – DanTheMan Sep 21 '11 at 20:59

1 Answers1

1

The Silverlight 4 HTTP networking stack is limited to 6 concurrent connections.

See here under the Client HTTP Processing section:

Concurrent connection limit is raised from 2 to 6

kevev22
  • 3,737
  • 21
  • 32
  • Well, that is disappointing. I don't suppose you know of any way around this? – DanTheMan Sep 21 '11 at 21:15
  • I am not sure about this, but it looks like the connection limit is by domain, so you might be able to set up multiple sub-domains that will serve 6 connections each. http://stackoverflow.com/questions/985431/max-parallel-http-connections-in-a-browser/985704#985704. Apparently this works for getting around the browser connection limit. If this does not work with the SL HTTP stack, you might be able to use the browser HTTP stack http://msdn.microsoft.com/en-us/library/dd920295(v=vs.95).aspx. – kevev22 Sep 21 '11 at 21:48
  • Using multiple subdomains seems hacky, and this is an enterprisey system that I'm not sure I can set up / explain to everyone why they need two subdomains. I guess we'll just switch to the browser stack for firefox. – DanTheMan Sep 22 '11 at 13:07