good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 0fef66c7 authored by Péter Szilágyi's avatar Péter Szilágyi
Browse files

ethstats: fix reconnection issue, implement primus pings

parent 9e88224e
No related branches found
No related tags found
No related merge requests found
......@@ -280,8 +280,10 @@ func (s *Service) loop() {
}
}
fullReport.Stop()
// Make sure the connection is closed
// Close the current connection and establish a new one
conn.Close()
errTimer.Reset(0)
}
}
}
......@@ -296,8 +298,23 @@ func (s *Service) readLoop(conn *websocket.Conn) {
for {
// Retrieve the next generic network packet and bail out on error
var blob json.RawMessage
if err := conn.ReadJSON(&blob); err != nil {
log.Warn("Failed to retrieve stats server message", "err", err)
return
}
// If the network packet is a system ping, respond to it directly
var ping string
if err := json.Unmarshal(blob, &ping); err == nil && strings.HasPrefix(ping, "primus::ping::") {
if err := conn.WriteJSON(strings.Replace(ping, "ping", "pong", -1)); err != nil {
log.Warn("Failed to respond to system ping message", "err", err)
return
}
continue
}
// Not a system ping, try to decode an actual state message
var msg map[string][]interface{}
if err := conn.ReadJSON(&msg); err != nil {
if err := json.Unmarshal(blob, &msg); err != nil {
log.Warn("Failed to decode stats server message", "err", err)
return
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment