我是Red5的新手。我决定构建我的第一个应用程序并前往https://github.com/Red5下载必要的软件。到目前为止,我已经安装了jre 8,jdk 1.8,Maven,flex SDK 4.6和Red5 1.0.5。我也安装了eclipse插件。我在Application.java中收到错误,说Application类型的层次结构不一致,而其他消息抱怨无法解析org.red5.server.api.Iconnect和 org.red5.server.api.scope.IScope。我可以通过从构建路径中删除red5.server.jar然后将其添加回来清除这些错误。但我必须使用org.red5.server.api.IScope而不是... api.scope.IScope才能工作。此时我猜我没有正确的red5.jar。我没有使用Flash builder来编译客户端,而是使用flex附带的mxmlc.exe。我得到swf文件然后我运行它但它不会连接(NetConnection.connect.failed)。我使用Eclipse Mars在本地运行它。
服务器
package org.red5.core;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
//import org.slf4j.Logger;
/**
* Sample application that uses the client manager.
*
* @author The Red5 Project (red5@osflash.org)
*/
public class Application extends MultiThreadedApplicationAdapter {
//private static Logger log = Red5LoggerFactory.getLogger(Application.class);
/** {@inheritDoc} */
@Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
//log.info("appConnect");
return true;
}
/** {@inheritDoc} */
@Override
public void disconnect(IConnection conn, IScope scope) {
//log.info("disconnect");
super.disconnect(conn, scope);
}
}
客户端
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="onCreationComplete(event)">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
private var connection:NetConnection;
public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.connect("rtmp://localhost/Project");
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
connection.client = this;
}
public function onConnectionNetStatus(event:NetStatusEvent) : void {
// did we successfully connect
if(event.info.code == "NetConnection.Connect.Success") {
Alert.show("Successful Connection", "Information");
} else {
Alert.show("Unsuccessful Connection", event.info.code);
}
}
]]>
</mx:Script>
</mx:Application>
运行client.swf
时[ERROR] [RTMPConnectionExecutor#OXEXJYYHVOTE2-1] org.red5.server.net.rtmp.BaseRTMPHandler - Exception
java.lang.NoClassDefFoundError: org/red5/server/api/IScope
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_45]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_45]
at java.lang.Class.privateGetMethodRecursive(Class.java:3048) ~[na:1.8.0_45]
at java.lang.Class.getMethod0(Class.java:3018) ~[na:1.8.0_45]
at java.lang.Class.getMethod(Class.java:1784) ~[na:1.8.0_45]
at org.red5.logging.Red5LoggerFactory.getLogger(Red5LoggerFactory.java:56) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.adapter.MultiThreadedApplicationAdapter.connect(MultiThreadedApplicationAdapter.java:297) ~[red5-server.jar:1.0.5-RELEASE]
at org.red5.server.scope.Scope.connect(Scope.java:255) ~[red5-server-common-1.0.5-RELEASE.jar:na]
at org.red5.server.BaseConnection.connect(BaseConnection.java:354) ~[red5-server-common-1.0.5-RELEASE.jar:na]
at org.red5.server.net.rtmp.RTMPConnection.connect(RTMPConnection.java:398) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.RTMPMinaConnection.connect(RTMPMinaConnection.java:87) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.RTMPHandler.onCommand(RTMPHandler.java:347) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:105) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:57) [red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:11) [red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: java.lang.ClassNotFoundException: org.red5.server.api.IScope
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) ~[tomcat-embed-core.jar:7.0.57]
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) ~[tomcat-embed-core.jar:7.0.57]
... 21 common frames omitted
[ERROR] [RTMPConnectionExecutor#DZX5W02SUWV7J-1] org.red5.server.net.rtmp.BaseRTMPHandler - Exception
java.lang.NoClassDefFoundError: org/red5/server/api/IScope
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_45]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_45]
at java.lang.Class.privateGetMethodRecursive(Class.java:3048) ~[na:1.8.0_45]
at java.lang.Class.getMethod0(Class.java:3018) ~[na:1.8.0_45]
at java.lang.Class.getMethod(Class.java:1784) ~[na:1.8.0_45]
at org.red5.logging.Red5LoggerFactory.getLogger(Red5LoggerFactory.java:56) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.adapter.MultiThreadedApplicationAdapter.connect(MultiThreadedApplicationAdapter.java:297) ~[red5-server.jar:1.0.5-RELEASE]
at org.red5.server.scope.Scope.connect(Scope.java:255) ~[red5-server-common-1.0.5-RELEASE.jar:na]
at org.red5.server.BaseConnection.connect(BaseConnection.java:354) ~[red5-server-common-1.0.5-RELEASE.jar:na]
at org.red5.server.net.rtmp.RTMPConnection.connect(RTMPConnection.java:398) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.RTMPMinaConnection.connect(RTMPMinaConnection.java:87) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.RTMPHandler.onCommand(RTMPHandler.java:347) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:105) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:57) [red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:11) [red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: java.lang.ClassNotFoundException: org.red5.server.api.IScope
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720) ~[tomcat-embed-core.jar:7.0.57]
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571) ~[tomcat-embed-core.jar:7.0.57]
... 21 common frames omitted
[WARN] [ConnectionChecker-1] org.red5.server.net.rtmp.RTMPConnManager - Connection OXEXJYYHVOTE2 has exceeded the max inactivity threshold
[WARN] [ConnectionChecker-1] org.red5.server.net.rtmp.RTMPConnManager - Connection not found for OXEXJYYHVOTE2