Monibuca / plugin-gb28181

gb28181 plugin for monibuca
GNU Affero General Public License v3.0
146 stars 95 forks source link

使用GB28181协议在订阅后流被断开该如何解决 #105

Closed CyberLife-Markus closed 9 months ago

CyberLife-Markus commented 9 months ago

使用设备为海康摄像头,配置如下:

image

config.yaml配置如下

llhls:
  enable: false
hls:
  enable: false
monitor:
  enable: false

global:
  pulseinterval: 5s # 心跳事件间隔时间

gb28181:
  invitemode:     1 #0、手动invite 1、表示自动发起invite,当Server(SIP)接收到设备信息时,立即向设备发送invite命令获取流,2、按需拉流,既等待订阅者触发
  position:
    autosubposition: false #是否自动订阅定位
    expires: 3600s #订阅周期(单位:秒),默认3600
    interval: 61s #订阅间隔(单位:秒),默认6
  sipip:          "" #sip服务器地址 默认 自动适配设备网段
  serial:         "34020000001110000001"
  realm:          "3402000000"
  username:       "34020000001110000001"
  password:       "12345678"
  registervalidity:  80s #注册有效期
  mediaip:          "" #媒体服务器地址 默认 自动适配设备网段
  port:
    sip: udp:5060 #sip服务器端口
    media: tcp:58200-59200 #媒体服务器端口,用于接收设备的流

  removebaninterval: 10m #定时移除注册失败的设备黑名单,单位秒,默认10分钟(600秒)
  loglevel:         debug

启用monibuca进程,查看8080/gb28181/api/list API接口返回如下:

[
  {
    "Channels": [
      {
        "Address": "192.168.254.3",
        "CivilCode": "CivilCode",
        "DeviceID": "34020000001310000001",
        "GpsTime": "0001-01-01T00:00:00Z",
        "Latitude": "",
        "LiveStatus": 0,
        "LiveSubSP": "",
        "Longitude": "",
        "Manufacturer": "Manufacturer",
        "Model": "Camera",
        "Name": "优曼测试",
        "Owner": "Owner",
        "ParentID": "",
        "Parental": 0,
        "Port": 0,
        "RegisterWay": 1,
        "SafetyWay": 0,
        "Secrecy": 0,
        "Status": "ON"
      },
      {
        "Address": "192.168.254.19",
        "CivilCode": "CivilCode",
        "DeviceID": "34020000001310000002",
        "GpsTime": "0001-01-01T00:00:00Z",
        "Latitude": "",
        "LiveStatus": 0,
        "LiveSubSP": "",
        "Longitude": "",
        "Manufacturer": "Manufacturer",
        "Model": "Camera",
        "Name": "Camera 01",
        "Owner": "Owner",
        "ParentID": "",
        "Parental": 0,
        "Port": 0,
        "RegisterWay": 1,
        "SafetyWay": 0,
        "Secrecy": 0,
        "Status": "OFF"
      }
    ],
    "ID": "34020000001110000001",
    "Name": "Network Video Recorder",
    "Manufacturer": "HIKVISION",
    "Model": "DS-7816N-R2/16P",
    "Owner": "",
    "RegisterTime": "2024-01-21T14:54:08.084150099+08:00",
    "UpdateTime": "2024-01-21T15:06:18.120260297+08:00",
    "LastKeepaliveAt": "2024-01-21T15:06:18.120381176+08:00",
    "Status": "ONLINE",
    "SN": 3,
    "SipIP": "172.18.156.34",
    "MediaIP": "172.18.156.34",
    "NetAddr": "171.106.18.191:62977",
    "GpsTime": "0001-01-01T00:00:00Z",
    "Longitude": "",
    "Latitude": ""
  }
]

访问:8080/preview/34020000001110000001/34020000001310000001播放视频流失败,STD输出如下:

15:13:57        DEBUG   Preview visit   {"path": "/preview/34020000001110000001/decoder-pro-hard.js", "remote": "222.71.242.202:56737"}
15:13:57        DEBUG   Preview visit   {"path": "/preview/34020000001110000001/decoder-pro-audio.wasm", "remote": "222.71.242.202:56737"}
15:13:58        DEBUG   HDL     visit   {"path": "/hdl/34020000001110000001/34020000001310000001.flv", "remote": "222.71.242.202:56737"}
15:13:58        INFO    已创建  {"流": "34020000001110000001/34020000001310000001", "id": 1}
15:13:58        DEBUG   warp context    {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737"}
15:13:58        INFO    订阅    {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737"}
15:13:58        DEBUG   GB28181 TryAutoInvite   {"id": "34020000001110000001", "channel": "34020000001310000001", "opt": "t=0 0", "condition": true}
15:13:58        INFO    订阅者+1        {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737", "remains": 1}
15:13:58        INFO    GB28181 invite response {"id": "34020000001110000001", "channel": "34020000001310000001", "status code": 200}
15:13:58        DEBUG   GB28181 Device support tcp      {"id": "34020000001110000001", "channel": "34020000001310000001"}
15:13:58        DEBUG   found   {"流": "34020000001110000001/34020000001310000001", "id": 1}
15:13:58        DEBUG   create context  {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "PSPublisher"}
15:13:58        INFO    发布    {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "PSPublisher", "ptr": "0xc000c135e0"}
15:13:58        INFO    ⌛->🟡    {"流": "34020000001110000001/34020000001310000001", "id": 1, "动作": "publish"}
15:13:58        INFO    tcp listen 1 at :58200
15:14:03        WARN    no tracks       {"流": "34020000001110000001/34020000001310000001", "id": 1}
15:14:03        INFO    🟡->🔴    {"流": "34020000001110000001/34020000001310000001", "id": 1, "动作": "timeout"}
15:14:03        INFO    close   {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "HDLSubscriber", "ID": "222.71.242.202:56737", "event": "close"}
15:14:03        INFO    close   {"流": "34020000001110000001/34020000001310000001", "id": 1, "类型": "PSPublisher", "event": "close"}

观察到的现象: 当播放失败后,8080/gb28181/api/list这个API的返回对象就会变为[]空数组 目前看起来连接是建立了,从报错内容来看是没有收到推流数据,想请教一下该如何排查问题。 服务器上的端口已经全部开放(1-60999)

CyberLife-Markus commented 9 months ago

已解决,摄像头带宽不够,推送时会断开连接,增大timeout时间问题解决