Red5 / red5-server

Red5 Server core
Apache License 2.0
3.34k stars 984 forks source link

Closing connection because decoding failed #87

Closed pleqtron closed 9 years ago

pleqtron commented 9 years ago

I am currently streaming (with my custom application, server-side as well as client.side) on an Adobe Media Server (formerly Flash Media Server). In my server-side actionscript I try to connect to my additional Red5 Server to push the stream to this instance as well.

I am doing the following in my main.asc:

application.mobilenc = new NetConnection();
    application.mobilenc.connect( "rtmp://xxxx:1936/camchat" );
    application.mobilenc.onStatus = function(info) {
      trace(info.code+"   camchat red5");
      if(info.code == "NetConnection.Connect.Success"){
          application.mobilens = new NetStream(application.mobilenc);
          application.mobilens.setBufferTime(3);
          application.mobilens.attach(streamObj);
          application.mobilens.publish("live"+clientObj.uid);

      }
    }

I can see the connection incoming to the red5 Server. So far so good. But directly after sending first bytes I will get some errors:

[ERROR] [NioProcessor-11] org.red5.server.net.rtmp.RTMPHandshake - Unable to validate client
[INFO] [NioProcessor-11] org.red5.server.net.rtmp.RTMPHandshake - Invalid RTMP connection data detected, you may experience errors
[INFO] [RTMPConnectionExecutor#3A4EO5XVF8MWA-1] org.red5.core.Application - appConnect
[INFO] [RTMPConnectionExecutor#3A4EO5XVF8MWA-1] org.red5.core.Application - [Ljava.lang.Object;@49601a0
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 110
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 120
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 71
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 74
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 77
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 105
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 118
[INFO] [NioProcessor-11] org.red5.io.amf3.Input - Unknown datatype: 101
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Closing connection because decoding failed: RTMPMinaConnection from 192.168.0.160 (in: 3512 out: 3287) session: 3A4EO5XVF8MWA state: connected
org.red5.server.net.protocol.ProtocolException: Error during decoding
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtocolDecoder.java:190) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeBuffer(RTMPProtocolDecoder.java:114) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.red5.server.net.rtmp.codec.RTMPMinaProtocolDecoder.decode(RTMPMinaProtocolDecoder.java:77) [red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:233) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:48) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:943) [mina-core-2.0.8.jar:na]
    at org.red5.server.net.rtmpe.RTMPEIoFilter.messageReceived(RTMPEIoFilter.java:132) [red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:48) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:943) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:109) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:542) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:535) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:714) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:668) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:657) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:67) [mina-core-2.0.8.jar:na]
    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1121) [mina-core-2.0.8.jar:na]
    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.8.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_40]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_40]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40]
Caused by: java.nio.BufferUnderflowException: null
    at java.nio.Buffer.nextGetIndex(Buffer.java:500) ~[na:1.8.0_40]
    at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:135) ~[na:1.8.0_40]
    at org.apache.mina.core.buffer.AbstractIoBuffer.get(AbstractIoBuffer.java:491) ~[mina-core-2.0.8.jar:na]
    at org.red5.io.amf3.Input.readDataType(Input.java:231) ~[red5-io-1.0.5-RELEASE.jar:na]
    at org.red5.io.object.Deserializer.deserialize(Deserializer.java:53) ~[red5-io-1.0.5-RELEASE.jar:na]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.handleParameters(RTMPProtocolDecoder.java:1160) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeInvoke(RTMPProtocolDecoder.java:856) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodeMessage(RTMPProtocolDecoder.java:526) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decodePacket(RTMPProtocolDecoder.java:371) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    at org.red5.server.net.rtmp.codec.RTMPProtocolDecoder.decode(RTMPProtocolDecoder.java:172) ~[red5-server-common-1.0.5-RELEASE.jar:1.0.5-RELEASE]
    ... 22 common frames omitted
[INFO] [NioProcessor-11] org.red5.core.Application - disconnect
[INFO] [NioProcessor-11] org.red5.core.Application - W3C x-category:session x-event:disconnect c-ip:192.168.0.160 c-client-id:9
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPConnManager - Connection not found for 3A4EO5XVF8MWA
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Connection was not found for 3A4EO5XVF8MWA, force closing
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Force close - session: 10
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPConnManager - Connection not found for 3A4EO5XVF8MWA
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Connection was not found for 3A4EO5XVF8MWA, force closing
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Force close - session: 10
[INFO] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Close already forced on this session: 10
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPConnManager - Connection not found for 3A4EO5XVF8MWA
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Connection was not found for 3A4EO5XVF8MWA, force closing
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Force close - session: 10
[INFO] [NioProcessor-11] org.red5.server.net.rtmp.RTMPMinaIoHandler - Close already forced on this session: 10
[WARN] [NioProcessor-11] org.red5.server.net.rtmp.RTMPConnManager - Connection not found for 3A4EO5XVF8MWA

If I connect via the Flash Media Live Encoder directly to the red5 Instance, everything works like a charm. Where is the difference? What am I doing wrong?

Best, Patrick

mondain commented 9 years ago

AMS is using a handshake routine which is unknown to Red5; the first two lines in your log dump allude to this. Until the routine is known, we won't be able to support this type of connection.

vishal-authorgen commented 9 years ago

According to Mondain, It is not possible to connect with RED5 from Adobe media server. Am I right ?

mondain commented 9 years ago

For testing, I'm using the dockerized version of AMS http://codesi.nz/docker/2015/09/17/dockerizing-adobe-media-server.html https://github.com/opreaadrian/docker-adobe-media-server

mondain commented 9 years ago

Successfully tested connecting to AMS 5.0.8 from Red5 Client and from AMS Server to Red5. The Red5 version used was 1.0.7-SNAPSHOT without any special modifications. The only issue I see at this time is in the initStream call made from AMS when creating a NetStream and until that is resolved, I'll keep this issue report open.

mondain commented 9 years ago

Similar Stackoverflow post that I made back in April 2015 http://stackoverflow.com/questions/29810697/adobe-ams-to-ams-initstream-method-call

mondain commented 9 years ago

I've updated red5 to handle the new methods called by AMS and have found that the play method uses some unknown object instead of the standard NetStream.play params we all know, so to work around this, you simply need to set AMF0 encoding on your server-side netconnection like so:

application.mobilenc = new NetConnection();
application.mobilenc.objectEncoding = 0;