From 6ab87947544dfffec0791b1999fbbb52946677e2 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 18 Sep 2020 21:54:23 +0200 Subject: [PATCH] proxy: improve logging and reconnecting --- proxy/pkg/server/api_ws.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proxy/pkg/server/api_ws.go b/proxy/pkg/server/api_ws.go index e24e21df7..57ff70cb8 100644 --- a/proxy/pkg/server/api_ws.go +++ b/proxy/pkg/server/api_ws.go @@ -55,7 +55,8 @@ func (ac *APIController) startWSHandler() { var wsMsg websocketMessage err := ac.wsConn.ReadJSON(&wsMsg) if err != nil { - ac.logger.Println("read:", err) + ac.logger.WithField("loop", "ws-handler").Println("read:", err) + ac.wsConn.CloseAndReconnect() return } if wsMsg.Instruction != WebsocketInstructionAck { @@ -64,7 +65,7 @@ func (ac *APIController) startWSHandler() { if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { err := ac.UpdateIfRequired() if err != nil { - ac.logger.WithError(err).Debug("Failed to update") + ac.logger.WithField("loop", "ws-handler").WithError(err).Debug("Failed to update") } } } @@ -78,7 +79,8 @@ func (ac *APIController) startWSHealth() { } err := ac.wsConn.WriteJSON(aliveMsg) if err != nil { - ac.logger.Println("write:", err) + ac.logger.WithField("loop", "ws-health").Println("write:", err) + ac.wsConn.CloseAndReconnect() return } }