Which is the best way to implement redundant live encoders in wowza? I have two encoders serving the same channel, if the primary encoder goes down I’d like to switch automatically to the secondary encoder without affecting the flash clients, if it possible I’d like the clients don’t need to press play again.
It should just work. If you have an encoder publishing and clients subscribing to:
Server: rtmp://[wowza-address]:1935/live
Stream: myStream
And if you turn off the encoder and start another one publishing to the same rtmp URL with the same stream name, clients will start receiving the stream from the 2nd encoder.
Some players might detect an interruption and display a message or shutdown so that the user has to restart, but you can modify that so it does happen. Look at the player’s NetStream NetStatusEvent handler and you willl see where you can disable that behavior.
The idea of running two, I’m not sure if it will work. Whichever one goes on last will be the one that clients get when they subscribe. If it fails, I don’t think the 2nd one will kick in unless it restarts.
Yes, that is another solution, assuming it is Flash player client. If it is IPhone, Silverlight or RTSP player/device, I don’t know if or how you could do it. But with a Flash client it would be easy. Just set up a callback function on the NetConnection to tell the player what to do. Setup the callback something like this:
var clientObj:Object = new Object();
clientObj.switchStream = function(streamName:String):void
{
trace(streamName);
// switch here
};
netconnection.client = clientObj;
netconnection.connect("rtmp://[wowza-address]/[appName]");
You can detect when a encoder is connected so you should be able to do this.
How I think it would work
Have 1 Application but three connection points
Have 3 Names
Encoder1
Encoder2
Viewer1
(Flash Media Encoder Strem: is the Name to change as an example )
Write a module so that when an encoder connects it registers it knows it is there. Viewer connects to Viewer1 the requests is transparently re-written to Encoder1 or Encoder2 depending on which one is available. You could add a preference into the module as well.
Not too much work, but definitely a couple of days and some testing required.
But in my case and in order to achieve automatic redundancy, both encoders are always on. If the primary goes down then use the secondary in an automatic way. So, if both encoders are publishing to the same multicast/unicast IP and port could it produce conflicts in wowza?
If this is not possible I would need to implement something on top of wowza to detect if the primary encoder is down and if yes then use the other one.
I have implemented a watchdog to find if the primary encoder is not streaming. Now my question is how to switch to the redundant stream without user intervention, I would like to know if it is possible to do it on server side only and what methods should I call.
I am using 2 encoders each one sending a TS over UDP stream to Wowza through different ports, then I suppose I should use the command to control the encoders in order they broadcast the same port and switching when the primary goes down?. But I don’t like this solution because is very dependent on the encoder API, so would it be possible to implement a reconnection on the player side?