diff --git a/MQTTnet.Core/Client/MqttClient.cs b/MQTTnet.Core/Client/MqttClient.cs index df3c61fac..3cec8d86d 100644 --- a/MQTTnet.Core/Client/MqttClient.cs +++ b/MQTTnet.Core/Client/MqttClient.cs @@ -238,7 +238,15 @@ private void FireApplicationMessageReceivedEvent(MqttPublishPacket publishPacket } var applicationMessage = publishPacket.ToApplicationMessage(); - ApplicationMessageReceived?.Invoke(this, new MqttApplicationMessageReceivedEventArgs(applicationMessage)); + + try + { + ApplicationMessageReceived?.Invoke(this, new MqttApplicationMessageReceivedEventArgs(applicationMessage)); + } + catch (Exception exception) + { + MqttTrace.Error(nameof(MqttClient), exception, "Unhandled exception while handling application message."); + } } private Task ProcessReceivedPublishPacket(MqttPublishPacket publishPacket)