File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -280,8 +280,10 @@ func (s *Service) loop() {
280280 }
281281 }
282282 fullReport .Stop ()
283- // Make sure the connection is closed
283+
284+ // Close the current connection and establish a new one
284285 conn .Close ()
286+ errTimer .Reset (0 )
285287 }
286288 }
287289}
@@ -296,8 +298,23 @@ func (s *Service) readLoop(conn *websocket.Conn) {
296298
297299 for {
298300 // Retrieve the next generic network packet and bail out on error
301+ var blob json.RawMessage
302+ if err := conn .ReadJSON (& blob ); err != nil {
303+ log .Warn ("Failed to retrieve stats server message" , "err" , err )
304+ return
305+ }
306+ // If the network packet is a system ping, respond to it directly
307+ var ping string
308+ if err := json .Unmarshal (blob , & ping ); err == nil && strings .HasPrefix (ping , "primus::ping::" ) {
309+ if err := conn .WriteJSON (strings .Replace (ping , "ping" , "pong" , - 1 )); err != nil {
310+ log .Warn ("Failed to respond to system ping message" , "err" , err )
311+ return
312+ }
313+ continue
314+ }
315+ // Not a system ping, try to decode an actual state message
299316 var msg map [string ][]interface {}
300- if err := conn . ReadJSON ( & msg ); err != nil {
317+ if err := json . Unmarshal ( blob , & msg ); err != nil {
301318 log .Warn ("Failed to decode stats server message" , "err" , err )
302319 return
303320 }
You can’t perform that action at this time.
0 commit comments