Why is the IPushPublishRTMPNotify's onConnectFailure() method never called?

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) {}
}

Can anyone help please? I’m still stuck with this issue.

Looks like this is a Wowza SDK bug in regards to the event that needs to trigger the onConnectFailure() function on the IPushPublishRTMPNotify interface.

Is there a way I can file a bug for this?

Hi David,

This has been addressed in your ticket #238336, but I wanted to copy my response here for others as well.

Since it looks like you are directly instantiating a PushPublishRTMP object, these events would not called. They would only be called if you have added the stream target through the PushPublishMap.txt file, and the push publish session is started through this higher-level API.

You can still monitor push publish sessions that are created through the lower-level PushPublishRTMP API by using the PushPublishUtils class coupled with a class that either implements IPushPublishRTMPNotify or PushPublishRTMPNotifyBase.

You will need to add the following call to your main publisher class. It should be after you have created the pushpublish session and added it to the appInstance:

PushPublishUtils.notifySessionCreate(streamName, stream, se, stream.getClient().getAppInstance());

You will also need to add the following after you have removed the pushpublish session from the appInstance.

  PushPublishUtils.notifySessionDestroy(streamName, stream, se, appInstance);

You will then need to add a listener for your IPushPublishRTMPNotify or PushPublishRTMPNotifyBase classes, where you can add your logic to notify for the session create and destroy events.

Michelle