# ModuleRTMPAuthenticate.onConnect

**URL:** https://community.wowza.com/t/modulertmpauthenticate-onconnect/29
**Category:** Wowza Developer Dojo
**Tags:** wowza-streaming-server-java-api
**Created:** [July 5, 2010, 10:55pm UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29 "2010-07-05T22:55:43Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)
#### Post date: [July 5, 2010, 10:55pm UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/1 "2010-07-05T22:55:43Z")

</div>

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:

```auto
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

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [July 5, 2010, 3:44pm UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/2 "2010-07-05T15:44:48Z")

</div>

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

[https://www.wowza.com/forums/showthread.php?p=33369](https://www.wowza.com/forums/showthread.php?p=33369)

Charlie

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [July 9, 2010, 3:37am UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/3 "2010-07-09T03:37:41Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Jeff\_Herrin](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@Jeff\_Herrin](https://community.wowza.com/u/Jeff_Herrin)
#### Post date: [July 6, 2010, 2:19am UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/4 "2010-07-06T02:19:55Z")

</div>

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?

[https://www.wowza.com/forums/showthread.php?p=33369](https://www.wowza.com/forums/showthread.php?p=33369)

Here’s the test code from that thread:

```auto
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

```auto
            <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

---

<div class="post-metadata">

### Author: ![Jeff\_Herrin](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@Jeff\_Herrin](https://community.wowza.com/u/Jeff_Herrin)
#### Post date: [July 6, 2010, 2:42pm UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/5 "2010-07-06T14:42:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Jeff\_Herrin](https://avatars.discourse-cdn.com/v4/letter/j/ec9cab/32.png) [@Jeff\_Herrin](https://community.wowza.com/u/Jeff_Herrin)
#### Post date: [July 9, 2010, 12:00am UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/6 "2010-07-09T00:00:57Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)
#### Post date: [July 6, 2010, 11:32am UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/7 "2010-07-06T11:32:12Z")

</div>

It is this post I am talking about:

[https://www.wowza.com/forums/showpost.php?p=33210&postcount=15](https://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://community.wowza.com/t/-/45](http://community.wowza.com/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

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [July 6, 2010, 12:45pm UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/8 "2010-07-06T12:45:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)
#### Post date: [July 6, 2010, 3:03pm UTC](https://community.wowza.com/t/modulertmpauthenticate-onconnect/29/9 "2010-07-06T15:03:18Z")

</div>

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

[http://community.wowza.com/t/-/242](http://community.wowza.com/t/-/242)

Richard
