proxy: fix high CPU when websocket not connected
This commit is contained in:
		| @ -65,8 +65,13 @@ func (ac *APIController) Shutdown() { | |||||||
| } | } | ||||||
|  |  | ||||||
| func (ac *APIController) startWSHandler() { | func (ac *APIController) startWSHandler() { | ||||||
|  | 	notConnectedBackoff := 1 | ||||||
| 	for { | 	for { | ||||||
| 		if !ac.wsConn.IsConnected() { | 		if !ac.wsConn.IsConnected() { | ||||||
|  | 			notConnectedWait := time.Duration(notConnectedBackoff) * time.Second | ||||||
|  | 			ac.logger.WithField("loop", "ws-handler").WithField("wait", notConnectedWait).Info("Not connected loop") | ||||||
|  | 			time.Sleep(notConnectedWait) | ||||||
|  | 			notConnectedBackoff += notConnectedBackoff | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		var wsMsg websocketMessage | 		var wsMsg websocketMessage | ||||||
| @ -76,9 +81,6 @@ func (ac *APIController) startWSHandler() { | |||||||
| 			ac.wsConn.CloseAndReconnect() | 			ac.wsConn.CloseAndReconnect() | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		if wsMsg.Instruction != WebsocketInstructionAck { |  | ||||||
| 			ac.logger.Debugf("%+v\n", wsMsg) |  | ||||||
| 		} |  | ||||||
| 		if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { | 		if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { | ||||||
| 			err := ac.UpdateIfRequired() | 			err := ac.UpdateIfRequired() | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens Langhammer
					Jens Langhammer