mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-28 10:04:59 +08:00
changed logging for server keepalive
This commit is contained in:
parent
ac013497c4
commit
4c5d21ec55
1 changed files with 9 additions and 10 deletions
|
@ -371,15 +371,12 @@ func MonitorKeepalive(ctx context.Context, client mqtt.Client, cfg *config.Clien
|
||||||
keepaliveval, ok := keepalive.Load(cfg.Node.Network)
|
keepaliveval, ok := keepalive.Load(cfg.Node.Network)
|
||||||
if ok {
|
if ok {
|
||||||
keepalivetime = keepaliveval.(time.Time)
|
keepalivetime = keepaliveval.(time.Time)
|
||||||
} else {
|
if !keepalivetime.IsZero() && time.Since(keepalivetime) > time.Second*120 { // more than 2+ minutes
|
||||||
ncutils.Log("unable to parse timestamp " + keepalivetime.String())
|
ncutils.Log("server keepalive not recieved recently, resubscribe to message queue")
|
||||||
continue
|
err := Resubscribe(client, cfg)
|
||||||
}
|
if err != nil {
|
||||||
if time.Since(keepalivetime) > time.Second*120 { // more than 2+ minutes
|
ncutils.Log("closing " + err.Error())
|
||||||
ncutils.Log("server keepalive not recieved recently, resubscribe to message queue")
|
}
|
||||||
err := Resubscribe(client, cfg)
|
|
||||||
if err != nil {
|
|
||||||
ncutils.Log("closing " + err.Error())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,7 +387,7 @@ func MonitorKeepalive(ctx context.Context, client mqtt.Client, cfg *config.Clien
|
||||||
func ServerKeepAlive(client mqtt.Client, msg mqtt.Message) {
|
func ServerKeepAlive(client mqtt.Client, msg mqtt.Message) {
|
||||||
var currentTime = time.Now()
|
var currentTime = time.Now()
|
||||||
keepalive.Store(parseNetworkFromTopic(msg.Topic()), currentTime)
|
keepalive.Store(parseNetworkFromTopic(msg.Topic()), currentTime)
|
||||||
ncutils.PrintLog("setting time: "+currentTime.String(), 1)
|
ncutils.PrintLog("received server keepalive at "+currentTime.String(), 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resubscribe --- handles resubscribing if needed
|
// Resubscribe --- handles resubscribing if needed
|
||||||
|
@ -538,6 +535,8 @@ func Hello(cfg *config.ClientConfig, network string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// == Private ==
|
||||||
|
|
||||||
func publish(cfg *config.ClientConfig, dest string, msg []byte) error {
|
func publish(cfg *config.ClientConfig, dest string, msg []byte) error {
|
||||||
// setup the keys
|
// setup the keys
|
||||||
trafficPrivKey, err := auth.RetrieveTrafficKey(cfg.Node.Network)
|
trafficPrivKey, err := auth.RetrieveTrafficKey(cfg.Node.Network)
|
||||||
|
|
Loading…
Reference in a new issue