Support RTSP、GB28181、SDK、Ehome Protocol video platform EasyCVR Support all video channels through GB28181 The protocol is cascaded to the superior national standard platform , And support the same channel cascade to multiple superior platforms , This operation brings convenience to many users .
however EasyCVR stay 1.0.34 In the version of ,EasyCVR Cascade to the national standard platform , When the subordinate platform displays the online status of the superior platform, the status update is abnormal .
EasyCVR The online status update of middle and higher level platforms is completed by timer , Determine the status of the superior platform by skipping packets in the national standard agreement center , But only when the superior platform is online , If there's a network problem , After the superior platform status is offline , It's not going to be timed . When the network returns to normal ,Easycvr The state of the superior platform in cannot be restored .
So we can fix the problem by fixing the judgment rules , The reference codes are as follows :
func (c *Client) StartKeepAlive() {
defer func() {
if err := recover(); err != nil {
err_logger.Error(fmt.Sprintf("%s\n", err))
err_logger.Error(fmt.Sprintln(string(debug.Stack())))
}
}()
timer := time.NewTicker(time.Duration(c.Cascade.KeepaliveInterval) * time.Second)
defer timer.Stop()
for !c.Stoped {
select {
case <-timer.C:
c.doKeepAlive()
case <-c.KeepAliveQuit:
c.ClientOnline(false)
log.Println(" The joint venture stopped :", c.Cascade.ID)
return
}
}
}
func (c *Client) doKeepAlive() {
req, _, err := c.MakeKeepAliveRequest(c.LocalSerial, c.Cascade.Realm)
if err != nil {
log.Println(" Cascaded heartbeat packet failed to pack ")
return
}
err = req.SendByTransport(c.Transport)
if err != nil {
log.Println(" Cascading heartbeat packet failed to send ", err.Error())
return
}
log.Println(" Joint insurance :", c.Cascade.ID)
res, err := c.WaitAck(req.HeaderMap["Call-ID"], req.HeaderMap["CSeq"])
if err != nil {
c.ClientOnline(false)
return
}
if res.StatusCode != 200 {
c.ClientOnline(false)
return
}else{
c.ClientOnline(true)
}
}