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() {
280
280
}
281
281
}
282
282
fullReport .Stop ()
283
- // Make sure the connection is closed
283
+
284
+ // Close the current connection and establish a new one
284
285
conn .Close ()
286
+ errTimer .Reset (0 )
285
287
}
286
288
}
287
289
}
@@ -296,8 +298,23 @@ func (s *Service) readLoop(conn *websocket.Conn) {
296
298
297
299
for {
298
300
// 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
299
316
var msg map [string ][]interface {}
300
- if err := conn . ReadJSON ( & msg ); err != nil {
317
+ if err := json . Unmarshal ( blob , & msg ); err != nil {
301
318
log .Warn ("Failed to decode stats server message" , "err" , err )
302
319
return
303
320
}
You can’t perform that action at this time.
0 commit comments