How to maintain an encoder/server connection on a problematic network

I occasionally get contacted by customers that are having problems keeping their Windows Media Encoder 9 Series encoder and Windows Media Services 2008 server connected.  Often it is simply that the network between the two is having some issues, however briefly.  Both the encoder and server have resiliency built in but network conditions can get to a point where the stream stops.  The server's publishing point may either stop or continue to run while it is attempting to reconnect.

 The best thing to do in this situation is to get the encoder and server setup to reconnect to each other whenever there is an error.  Since the encoder supports both push and pull connections, there is a method that works best for each connection type.

Encoder Pull

Typically a broadcast publishing point on WMS simply points to the encoder HTTP URL.  Most of the time this is okay, but again if the network is having problems it may not be enough.  What you can do is setup a server side playlist (WSX) to attempt to reconnect if there is a problem. WMS itself will try to do that on the same TCP session, but this workaround will establish a new session and give the network a few seconds to recover.  Here's the playlist:

<?wsx  version="1.0" encoding="utf-8"?>
<smil repeatCount="indefinite">
    <media src="http://encoder:8080?wmreconnect=0"/>
    <media src="c:\wmpub\wmroot\proseware_leadin.jpg" dur="10"/>

There are three things to point out here.  First you will see that the first media item in the playlist is our connection to the encoder.  I've added the wmreconnect=0 query string.  This turns off the WMS reconnection logic.  We're doing this because if there is any sort of problem we want the server to immediately fail and roll to the next item in the playlist.  Second, is the next item in the playlist.  Above I have just pointed it to a JPG file that's one of the samples that comes with WMS.  I've set it to play for 10 seconds, but you could set it to a shorter time.  You could change this piece of content to any number of things.  You could use a "sorry we're having technical difficulties" video or JPG.  You could set it to a JPG file that is completely black.  Or you could point it to a different encoder machine.  That's actually the best option if you have two separate encoders encoding the same content.  This gives you a lot of redundency.  The only thing you can't use is the same encoder URL as the first one.  WMS sees this as the same playlist item and does not reconnect in the same way.  Third we have the SMIL repeatCount set to "indefinite".  This causes the items between the SMIL and /SMIL tags to be repeated for as long as the publishing point is running.

 Encoder Push

With push it is a little different. Instead of the server being responsible for maintaining the connection, now the encoder is responsible for maintaining the connection.  Since Windows Media Encoder does not have playlist functionality we created some hotfixes to help with the reconnection issues.

1a) Install fix from if running WME on Windows Vista.
1b) Install fix from if running WME on Windows XP.

2) Make the registry changes (but do not install the hotfix from)

With these fixes installed the encoder should keep attempting to reconnect to the server until it gets a connection.