Monibuca / plugin-rtmp

RTMP协议插件,提供RTMP协议的server功能:接收rtmp推流和rtmp的播放功能
MIT License
94 stars 51 forks source link

在摄像机(例如大华设备)配置rtmp推流,会重复的建立连接;设备会主动删除流,再次建立连接,一只重复; #21

Closed daxiong0327 closed 1 year ago

langhuihui commented 1 year ago

日志发出来看看

daxiong0327 commented 1 year ago

18:11:38 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "connect", "streamID": 0} 18:11:38 INFO plugin-rtmp/server.go:71 connect {"plugin": "RTMP", "appName": "live", "objectEncoding": 0} 18:11:38 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "releaseStream", "streamID": 0} 18:11:38 INFO plugin-rtmp/msg.go:325 decode command amf0 {"plugin": "RTMP", "cmd": "FCPublish"} 18:11:38 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "FCPublish", "streamID": 0} 18:11:38 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "createStream", "streamID": 0} 18:11:38 INFO plugin-rtmp/server.go:97 createStream: {"plugin": "RTMP", "streamId": 1} 18:11:38 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "deleteStream", "streamID": 0} 18:11:38 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "deleteStream", "streamID": 1} 18:11:39 INFO plugin-rtmp/server.go:172 rtmp client closed {"plugin": "RTMP", "remote": "172.31.100.59:41614"} 18:11:44 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "connect", "streamID": 0} 18:11:44 INFO plugin-rtmp/server.go:71 connect {"plugin": "RTMP", "appName": "live", "objectEncoding": 0} 18:11:44 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "releaseStream", "streamID": 0} 18:11:44 INFO plugin-rtmp/msg.go:325 decode command amf0 {"plugin": "RTMP", "cmd": "FCPublish"} 18:11:44 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "FCPublish", "streamID": 0} 18:11:44 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "createStream", "streamID": 0} 18:11:44 INFO plugin-rtmp/server.go:97 createStream: {"plugin": "RTMP", "streamId": 2} 18:11:44 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "deleteStream", "streamID": 0} 18:11:44 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "publish", "streamID": 2} 18:11:44 INFO engine/plugin.go:212 publish {"plugin": "RTMP", "path": "live/test1"} 18:11:44 INFO engine/stream.go:268 created {"stream": "live/test1"} 18:11:44 INFO engine/stream.go:285 ⌛->🟢 {"stream": "live/test1", "action": "publish"} 18:11:44 WARN plugin-rtmp/server.go:175 ReadMessage {"plugin": "RTMP", "error": "read tcp 172.31.13.165:1935->172.31.100.59:41620: read: connection reset by peer"} 18:11:48 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "connect", "streamID": 0} 18:11:48 INFO plugin-rtmp/server.go:71 connect {"plugin": "RTMP", "appName": "live", "objectEncoding": 0} 18:11:49 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "releaseStream", "streamID": 0} 18:11:49 INFO plugin-rtmp/msg.go:325 decode command amf0 {"plugin": "RTMP", "cmd": "FCPublish"} 18:11:49 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "FCPublish", "streamID": 0} 18:11:49 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "createStream", "streamID": 0} 18:11:49 INFO plugin-rtmp/server.go:97 createStream: {"plugin": "RTMP", "streamId": 3} 18:11:49 INFO engine/stream.go:285 🟢->⌛ {"stream": "live/test1", "action": "publish lost"} 18:11:49 DEBUG engine/stream.go:418 timeout {"stream": "live/test1", "state": "⌛"} 18:11:49 INFO engine/stream.go:285 ⌛->🔴 {"stream": "live/test1", "action": "timeout"} 18:11:49 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "deleteStream", "streamID": 0} 18:11:49 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "publish", "streamID": 3} 18:11:49 INFO engine/plugin.go:212 publish {"plugin": "RTMP", "path": "live/test1"} 18:11:49 INFO engine/stream.go:268 created {"stream": "live/test1"} 18:11:49 INFO engine/stream.go:285 ⌛->🟢 {"stream": "live/test1", "action": "publish"} 18:11:49 WARN plugin-rtmp/server.go:175 ReadMessage {"plugin": "RTMP", "error": "read tcp 172.31.13.165:1935->172.31.100.59:41624: read: connection reset by peer"} 18:11:53 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "connect", "streamID": 0} 18:11:53 INFO plugin-rtmp/server.go:71 connect {"plugin": "RTMP", "appName": "live", "objectEncoding": 0} 18:11:54 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "releaseStream", "streamID": 0} 18:11:54 INFO plugin-rtmp/msg.go:325 decode command amf0 {"plugin": "RTMP", "cmd": "FCPublish"} 18:11:54 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "FCPublish", "streamID": 0} 18:11:54 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "createStream", "streamID": 0} 18:11:54 INFO plugin-rtmp/server.go:97 createStream: {"plugin": "RTMP", "streamId": 4} 18:11:54 INFO engine/stream.go:285 🟢->⌛ {"stream": "live/test1", "action": "publish lost"} 18:11:54 DEBUG engine/stream.go:418 timeout {"stream": "live/test1", "state": "⌛"} 18:11:54 INFO engine/stream.go:285 ⌛->🔴 {"stream": "live/test1", "action": "timeout"} 18:11:54 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "deleteStream", "streamID": 0} 18:11:54 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "publish", "streamID": 4} 18:11:54 INFO engine/plugin.go:212 publish {"plugin": "RTMP", "path": "live/test1"} 18:11:54 INFO engine/stream.go:268 created {"stream": "live/test1"} 18:11:54 INFO engine/stream.go:285 ⌛->🟢 {"stream": "live/test1", "action": "publish"} 18:11:54 WARN plugin-rtmp/server.go:175 ReadMessage {"plugin": "RTMP", "error": "read tcp 172.31.13.165:1935->172.31.100.59:41628: read: connection reset by peer"} 18:11:59 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "connect", "streamID": 0} 18:11:59 INFO plugin-rtmp/server.go:71 connect {"plugin": "RTMP", "appName": "live", "objectEncoding": 0} 18:11:59 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "releaseStream", "streamID": 0} 18:11:59 INFO plugin-rtmp/msg.go:325 decode command amf0 {"plugin": "RTMP", "cmd": "FCPublish"} 18:11:59 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "FCPublish", "streamID": 0} 18:11:59 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "createStream", "streamID": 0} 18:11:59 INFO plugin-rtmp/server.go:97 createStream: {"plugin": "RTMP", "streamId": 5} 18:11:59 INFO engine/stream.go:285 🟢->⌛ {"stream": "live/test1", "action": "publish lost"} 18:11:59 DEBUG engine/stream.go:418 timeout {"stream": "live/test1", "state": "⌛"} 18:11:59 INFO engine/stream.go:285 ⌛->🔴 {"stream": "live/test1", "action": "timeout"} 18:11:59 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "deleteStream", "streamID": 0} 18:11:59 DEBUG plugin-rtmp/server.go:59 recv cmd {"plugin": "RTMP", "commandName": "publish", "streamID": 5} 18:11:59 INFO engine/plugin.go:212 publish {"plugin": "RTMP", "path": "live/test1"} 18:11:59 INFO engine/stream.go:268 created {"stream": "live/test1"} 18:11:59 INFO engine/stream.go:285 ⌛->🟢 {"stream": "live/test1", "action": "publish"} 18:12:00 WARN plugin-rtmp/server.go:175 ReadMessage {"plugin": "RTMP", "error": "read tcp 172.31.13.165:1935->172.31.100.59:41632: read: connection reset by peer"}

daxiong0327 commented 1 year ago

总是重复的接收请求,响应请求

langhuihui commented 1 year ago

我得找台大华测一下

daxiong0327 commented 1 year ago

好的,我这边也调一下

daxiong0327 commented 1 year ago

昨天的问题大概定位到了,是这样的: 设备端暂定叫client,服务端暂定叫server。 client主动向server发送: C0+C1 server回复client: S0+S1+S2 client回复server: C2 之后就是建立连接; client向server发送commend:releaseStream()、FCPublish() 和 createStream() server向client 发送了releaseStream_error(); ------》至此,client 因为收到了,releaseStream_error,会主动触发,deleteStream(); server没有向client,回复deleteStream_result(); client会认为server处理出现问题重新发起连接;至此开始下一轮循环;


releaseStream的处理代码 image

langhuihui commented 1 year ago

我研究一下

daxiong0327 commented 1 year ago

👌

langhuihui commented 1 year ago

可能是因为发了releaseStream_error引起的,我看有的服务器收到releaseStream后不会返回消息,可以先这么改试试

daxiong0327 commented 1 year ago

是的我注释掉,是可以正常接收rtmp流,但是有个逻辑隐患,是若推送的rtmp流的stremPath和已有的流重复,是选择覆盖还是向client返回错误;

langhuihui commented 1 year ago

应该是覆盖

daxiong0327 commented 1 year ago

好的