# Liverepeater-edge play() problem with invalid stream

**URL:** <https://community.wowza.com/t/liverepeater-edge-play-problem-with-invalid-stream/38708>\
**Category:** Wowza Streaming Engine\
**Created:** [July 17, 2014, 7:36am UTC](https://community.wowza.com/t/liverepeater-edge-play-problem-with-invalid-stream/38708 "2014-07-17T07:36:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ze\_Alves](https://avatars.discourse-cdn.com/v4/letter/z/e36b37/32.png) [@Ze\_Alves](https://community.wowza.com/u/Ze_Alves)\
**Post date:** [July 17, 2014, 7:36am UTC](https://community.wowza.com/t/liverepeater-edge-play-problem-with-invalid-stream/38708/1 "2014-07-17T07:36:40Z")

</div>

Hi, i have a problem in my wowza plataform.

For example:

I have 1 origin server and 1 edge server.

In my edge server i have rtmp://HOST…

When the edge call the origin url if the stream is not valid is possible to give a error “rtmp Failed to play streamname; stream not found”.

I had a plugin that overwrites plays in the edge servers:

```auto
public void play(IClient client, RequestFunction function,
			AMFDataList params) {
		if (!ret.getStatus()) {
		
			client.rejectConnection("NetConnection.Connect.Rejected.");
			client.shutdownClient();
		} else {
			ModuleCore.play(client, function, params);
		}

```

---

<div class="post-metadata">

**Author:** ![Matt\_Young](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/matt_young/32/389_2.png) [@Matt\_Young](https://community.wowza.com/u/Matt_Young)\
**Post date:** [July 17, 2014, 10:46am UTC](https://community.wowza.com/t/liverepeater-edge-play-problem-with-invalid-stream/38708/2 "2014-07-17T10:46:05Z")

</div>

It sounds like you might be looking to dynamically resolve the origin. If this is the case, you might checkout the following [IMediaStreamNameAliasProvider2](https://www.wowza.com/docs/how-to-use-event-listeners-in-wowza-media-server#IMediaStreamNameAliasProvider2) interface.

---

<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 17, 2014, 9:25pm UTC](https://community.wowza.com/t/liverepeater-edge-play-problem-with-invalid-stream/38708/3 "2014-07-17T21:25:01Z")

</div>

One way to check if an origin stream is running is to ask the origin using a Module or HTTPProvider. For example, with a module like this on the origin, a Flash RTMP client could connect to the origin and find out if the stream is live.

```auto
package test;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.IMediaStream;
import com.wowza.wms.stream.MediaStreamMap;
public class ModuleCheckStream extends ModuleBase {
	public void isStreamLive(IClient client, RequestFunction function,
			AMFDataList params) {
				
		Boolean streamExists = false; 
		String streamName = getParamString(params, PARAM1);
		
		client.getAppInstance().getPublishStreamNames().contains(streamName);
		
		MediaStreamMap streams = client.getAppInstance().getStreams();
		IMediaStream stream = streams.getStream(streamName);
		
		if (stream != null)
			streamExists = true;
		
		sendResult(client, params, streamExists);
		
	}
}

```

Or use an HTTPProvider

```auto
package test;
import java.io.*;
import java.util.List;
import java.util.Map;
import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.http.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.vhost.*;
public class HTTPOriginStreamCheck extends HTTProvider2Base {
	public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
		if (!doHTTPAuthentication(vhost, req, resp))
			return;
		
		String retStr = "false";
		String streamName = "myStream";
		String app = "live";
		
		req.parseBodyForParams(true);
		Map<String, List<String>> params = req.getParameterMap();
		if (params.containsKey("app")) 
			app = params.get("app").get(0);
		
			if (params.containsKey("streamname")) 
				streamName = params.get("streamname").get(0);
				
				IApplicationInstance appInstance = vhost.getApplication(app).getAppInstance("_definst_");
				if (appInstance.getPublishStreamNames().contains(streamName))
				{
					retStr = "true";
				}
		try {
			OutputStream out = resp.getOutputStream();
			byte[] outBytes = retStr.getBytes();
			out.write(outBytes);
		} catch (Exception e) {
			WMSLoggerFactory.getLogger(null).error(
					"HTTPOriginStreamCheck: " + e.toString());
		}
	}
}

```

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 17, 2014, 10:07pm UTC](https://community.wowza.com/t/liverepeater-edge-play-problem-with-invalid-stream/38708/4 "2014-07-17T22:07:36Z")

</div>

Or you could use resolvePlayAlias in the [IMediaStreamNameAliasProvider2](https://www.wowza.com/docs/how-to-use-the-imediastreamnamealiasprovider2-interface) and use the same method to see the stream is published. In this case you will look on the edge. This would give you the opportunity to send a message to the Flash RTMP client (which you can listen for with the NetConnection NetStatusEvent handler), and/or return another stream instead

```auto
public String resolvePlayAlias(IApplicationInstance appInstance,
			String name, IClient client) {
		getLogger().info("Resolve Play Flash: " + name);
		
		if (!appInstance.getPublishStreamNames().contains(name))
		{
			sendClientOnStatusError(client, "error.code", "description");// you are sending to the NetConnection in this case rather than the NetStream, which is a little awkward, but if the client is custom you can do whatever you want with notifications 
// OR (instead of line above), you could create a server-side stream and return a reference to it, or have one running (using the scheduler) for this purpose and just return the name 		
			Stream stream = Stream.createInstance(appInstance, "newStream"); // this might already exist, a looping server-side stream you use for filler.
			stream.play("mp4:sample.mp4", 0, -1, true);
			return "newStream";
		}
		
		return name;
	}

```
