Explorar el Código

fix(source): handle mqtt subscription errors gracefully

Signed-off-by: Jianxiang Ran <rxan_embedded@163.com>
Jianxiang Ran hace 2 años
padre
commit
8701f5e39a
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  1. 6 1
      internal/topo/connection/clients/mqtt/mqtt_wrapper.go

+ 6 - 1
internal/topo/connection/clients/mqtt/mqtt_wrapper.go

@@ -88,7 +88,12 @@ func (mc *mqttClientWrapper) onConnectHandler(_ pahoMqtt.Client) {
 		token := mc.cli.conn.Subscribe(topic, subscription.qos, subscription.topicHandler)
 		if token.Error() != nil {
 			for _, con := range subscription.topicConsumers {
-				con.SubErrors <- token.Error()
+				select {
+				case con.SubErrors <- token.Error():
+					break
+				default:
+					conf.Log.Warnf("consumer SubErrors channel full for request id %s", con.ConsumerId)
+				}
 			}
 		}
 	}