I’m currently publishing my stream to 2 other Wowza Live servers. I’m trying to handle the use case where 1 or more of these servers go down.
I created a class implementing the interface IPushPublishRTMPNotify, and added it to the publisher’s listeners. I then brought down 1 of the servers and tried to capture the connection failure, but that doesn’t seem to work. I notice that the class’s onConnectSuccess method is called every time the connect attempt is started. But, on connection failure, the onConnectFailure method is not called.
Is this a bug? Why isn’t the onConnectFailure() called? Is there something wrong in my code?
Here is my code:
Main Publisher class has this:
------------------------------
try
{
PushPublishRTMP publisher = new PushPublishRTMP();
PushPublishRTMPNotifier pushPublishRTMPNotifier = new PushPublishRTMPNotifier(hostName, publisher, this);
publisher.addListener(pushPublishRTMPNotifier);
String flashVersion = PushPublishRTMP.CURRENTFMLEVERSION;
publisher.setConnectionFlashVersion(flashVersion);
publisher.setAppInstance(appInstance);
publisher.setSrcStreamName(streamName);
publisher.setHost(hostName);
publisher.setPort(1935);
publisher.setDstStreamName(streamName);
publisher.setDstApplicationName(appName);
publisher.setAdaptiveStreaming(true);
publisher.setSendOriginalTimecodes(true);
publisher.setOriginalTimecodeThreshold(0x100000);
publisher.setSendFCPublish(true);
publisher.setSendOnMetadata(true);
publisher.setSendReleaseStream(true);
publisher.setSendStreamCloseCommands(true);
publisher.setDebugLog(true);
publisher.setDebugPackets(false);
IMediaStream stream = appInstance.getStreams().getStream(streamName);
appInstance.addPushPublishSession(stream, publisher.createPushPublishSession());
publisher.setEntryName(streamName + Integer.toString((int) Math.ceil(Math.random() * 1000)));
publisher.connect();
}
catch(Exception e)
{
WMSLoggerFactory.getLogger(null).error("setPublisher: Error in setting publisher for " + streamName + ": " + e.toString());
}
PushPublishRTMPNotifier class:
------------------------------
public class PushPublishRTMPNotifier implements IPushPublishRTMPNotify
{
@Override
public void onConnect(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params)
{
WMSLoggerFactory.getLogger(null).info("------REACHED CONNECT");
}
@Override
public void onConnectStart(PushPublishRTMPNetConnectionSession pushPublisherSession)
{
WMSLoggerFactory.getLogger(null).info("------REACHED CONNECT START");
}
@Override
public void onConnectSuccess(PushPublishRTMPNetConnectionSession pushPublisherSession)
{
WMSLoggerFactory.getLogger(null).info("------REACHED CONNECT SUCCESS");
}
@Override
public void onHandshakeResult(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params)
{
WMSLoggerFactory.getLogger(null).info("------REACHED HANDSHAKE RESULT");
}
@Override
public void onConnectFailure(PushPublishRTMPNetConnectionSession pushPublisherSession)
{
WMSLoggerFactory.getLogger(null).info("------REACHED CONNECT FAILURE");
}
@Override
public void onAkamaiClientLogin(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onAkamaiSetChallenge(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onAkamaiSetOriginConnectionInfo(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onFCAnnounce(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onFCPublish(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onPublishHandlerPlay(PushPublishRTMPNetConnectionSession pushPublisherSession, OutputStream out, long[] playSizes) {}
@Override
public void onPushPublisherSessionCreate(PushPublishRTMPNetConnectionSession pushPublisherSession) {}
@Override
public void onPushPublisherSessionDestroy(PushPublishRTMPNetConnectionSession pushPublisherSession) {}
@Override
public void onReleaseStream(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onSessionClosed(PushPublishRTMPNetConnectionSession pushPublisherSession) {}
@Override
public void onSessionIdle(PushPublishRTMPNetConnectionSession pushPublisherSession) {}
@Override
public void onSessionOpened(PushPublishRTMPNetConnectionSession pushPublisherSession) {}
@Override
public void onStreamCreate(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onStreamOnPlayStatus(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onStreamOnStatus(PushPublishRTMPNetConnectionSession pushPublisherSession, RequestFunction function, AMFDataList params) {}
@Override
public void onValidateSession(PushPublishRTMPNetConnectionSession pushPublisherSession) {}
@Override
public void onValidateSessionResult(PushPublishRTMPNetConnectionSession pushPublisherSession, boolean result) {}
}