Wowza Community

ModuleRTMPAuthenticate.onConnect

I’m trying to put together a module that authenticates users against our database instead of the the publish.password file.

I’m using Adobe Flash Media Encoder to do streaming.

It looks like I need to implement ModuleRTMPAuthenticate.onConnect, but onConnect doesn’t seem to like people playing with it.

FME connects, but when I try to Publish, I always get:

Status: NetStream.Publish.Failed

No other info is provided, even in the logs.

Also, I’ve tried it with and without the rtmpEncoderAuthenticatorFile property in Application.xml. It doesnt seem to make a difference.

Here’s some test code I was running:

public class testAuthentication extends ModuleRTMPAuthenticate{
    public void onConnect(IClient client, RequestFunction function,AMFDataList params) {
        getLogger().info("testAuthentication.onConnect");
        client.acceptConnection();
    }
}

On a side note, I can accomplish what I want to do using the publish() method from ModuleBase, but it doesn’t fail as gracefully…there’s no pop-up box that appears for user/pass (has to be passed in then URL), and it FME hangs for a couple seconds when it receives client.rejectConnection() from publish().

So I’d really like it to behave like a “regular” FME session…password pop-up on connect, etc.

Any insight would be greatly appreciated.

thanks,

altimage

See this forum post. It talks about a way to plug into authentication directly:

http://www.wowza.com/forums/showthread.php?p=33369

Charlie

Look at the javadocs for the base class you are extending. Based on the type of connection you should be getting appropriate context information.

Charlie

I’m streaming from Adobe FME with RTMP. But this class just doesn’t seem to get executed. It never shows the logging.

The post on authentication seems to eventually implement some classes with RTP and RTSP. Would these apply using RTMP?

http://www.wowza.com/forums/showthread.php?p=33369

Here’s the test code from that thread:

import com.wowza.wms.rtp.model.*;
import com.wowza.wms.application.*;
import com.wowza.wms.module.*;
import com.wowza.wms.logging.WMSLogger.*;
public class ModuleAccessControlRTSP extends ModuleBase
{
	public void onRTPSessionCreate(RTPSession rtpSession)
	{
		boolean isGood = true;
		String ipAddress = rtpSession.getIp();
		String queryStr = rtpSession.getQueryStr();
		String referrer = rtpSession.getReferrer();
		String userAgent = rtpSession.getUserAgent();
		
		IApplicationInstance appInstance = rtpSession.getAppInstance();
		String uriStr = rtpSession.getUri();
                 WMSLogger.getlogger(ipAddress);
                 WMSLogger.getlogger(queryStr);
                 WMSLogger.getlogger(referrer);
                 WMSLogger.getlogger(userAgent);
		
		// Here you can use the request and session information above to determine 
		// if you want to reject the connection
		// isGood = true/false;
		
		if (!isGood)
			rtpSession.rejectSession();
	}
}

These are in my Application.xml

            <Module>
                   <Name>ModuleRTMPAuthenticate</Name>
                   <Description>ModuleRTMPAuthenticate</Description>
                   <Class>com.wowza.wms.plugin.security.moduleRTPMAuthenticate</Class>
            </Module>
             <Module>
                   <Name>ModuleAccessControlRTSP</Name>
                   <Description>ModuleAccessControlRTSP</Description>
                   <Class>com.test.wowza.ModuleAccessControlRTSP</Class>
            </Module>
            <Property>
                <Name>rtmpEncoderAuthenticateFile</Name>
                <Value>${com.wowza.wms.context.VHostConfigHome}/conf/${com.wowza.wms.context.Application}/publish.password</Value>
            </Property>

I’ve tried switching the order of the modules, basic & digest authentication and looked around for RTMP specific functions. Any idea what I may be doing wrong?

Thanks for you help!

altimage

Is there a similar event that I could tap into for RTMP streaming?

Thanks for your help. I’ve got the authentication working now. But I was hoping I could get a reference to the the client within the getPassword() method. Something like:

client.getUri();

client.getIp();

thanks,

altimage

It is this post I am talking about:

http://www.wowza.com/forums/showpost.php?p=33210&postcount=15

This will work with RTSP and RTMP. You need to turn on RTMP authentication as described in this package:

http://www.wowza.com/community/t/-/45

Then if you implement a class as described here and set the property in the application properties then it will call your class to do the authentication.

Charlie

This event is not related to RTMP streaming. This would run when you start re-streaming from an IP camera that has an rtsp url, for example.

Richard

Yes, sorry: onStreamCreate, and onStreamDestroy. And the related IMediaStreamActionNotify2 interface and stream event handlers. See this post:

http://www.wowza.com/community/t/-/242

Richard