zoukankan      html  css  js  c++  java
  • 视频综合管理平台EasyNVS显示的rtsp和rtmp穿透地址错误如何解决?

    上一篇我们讲到由于有用户有rtsp和rtmp的地址做内部穿透的需求,所以我们在EasyNVS上增加了这个功能(EasyNVS通道列表如何获得RTMP地址和RTSP地址)。当目前的系统无法满足部分用户的需求时,我们会针对需求进行调整,达到效果。

    EasyNVS通道列表rtsp和rtmp穿透地址错误

    在测试的时候,我们偶尔会发现EasyNVR接到EasyNVS平台,EasyNVS平台通道列表出现的rtsp和rtmp穿透地址是错误的。对于这一点我们也进行了原因分析。

    原因分析

    因为在设备下线的时候,需要删除穿透的信息。但是在去数据库中查询设备穿透的时候,出现了空的现象,此时代码中没有进行非空校验,导致出现错误的穿透结果。

    错误复现:

    根据此代码可以复现该错误:

    //删除设备穿透表
    var sysTunnel models.SysTunnel
    db.SQLite.First(&sysTunnel)
    if sysTunnel.PortFreeList != "" {
       sysTunnel.PortFreeList += ","
    }
    var deviceTunnel models.DeviceTunnel
    db.SQLite.Where("device_id = ?", conf.DeviceID).First(&deviceTunnel)
    
    sysTunnel.PortFreeList += strconv.Itoa(deviceTunnel.RemoteRtspPort) + "," + strconv.Itoa(deviceTunnel.RemoteRtmpPort)
    db.SQLite.Save(&sysTunnel)
    db.SQLite.Delete(&deviceTunnel)
    

    问题解决:

    我们将代码进行了简单修改:

    //删除设备穿透表
    var sysTunnel models.SysTunnel
    db.SQLite.First(&sysTunnel)
    if sysTunnel.PortFreeList != "" {
       sysTunnel.PortFreeList += ","
    }
    var deviceTunnel models.DeviceTunnel
    db.SQLite.Where("device_id = ?", conf.DeviceID).First(&deviceTunnel)
    if deviceTunnel.ID != 0 {
       sysTunnel.PortFreeList += strconv.Itoa(deviceTunnel.RemoteRtspPort) + "," + strconv.Itoa(deviceTunnel.RemoteRtmpPort)
       db.SQLite.Save(&sysTunnel)
       db.SQLite.Delete(&deviceTunnel)
    }
    

    修改后的界面如下,错误已经解决了。

  • 相关阅读:
    python-Web-django-路由保护
    python-Web-django-图表统计
    python-linux-集群nginx
    python-Web-数据库-oracle
    python-Web-数据库-mysql
    python-爬虫-scrapy
    Educational Codeforces Round 90 (Rated for Div. 2) A~C
    leetcode周赛192
    Codeforces Round #597 (Div. 2) C dp
    Codeforces Round #645 (Div. 2) A~D
  • 原文地址:https://www.cnblogs.com/EasyNVR/p/13444367.html
Copyright © 2011-2022 走看看