How does the exception handling work for the message/topic events? #2042
Unanswered
stefan-nearbystore
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all!
So I'm working on a "system controller"/console application that shall monitor and control a few control units via MQTT.
Connecting to a cloud based (right now ...) broker/server (tried both HiveMQ and emqx).
In the application I have, as of right now, three client instances contained in separate own developed "client handlers" that add some extra functionality on top of the MQTTnet client.
I'm adding two event functions to all three of these clients for handling incoming MQTT messages/topics.
The code looks like this:
It's "in development" so I have both a check if there are "first connect" if doing the connect for the first time and both removing and adding the two functions (first LogReceivedMessages and second receivedMessageEvent) as of now (what is best I also do not know :-) ..).
The log function looks like this:
and is for being able to log incoming messages if that is activated.
The second looks like this and is added as reference via the "receivedMessageEvent" function variable:
So this one throws an exception!
Now to the questions:
The exception do not show up in the the console application windows but can be seen in the Visual Studio 2022 window for the debug output. Why?
If I change the order of how the events are added (so instead first adding receivedMessageEvent and second LogReceivedMessages) the second, LogReceivedMessages, are not triggered at all. So the first function are triggered which can be seen from the debug output. BUT then the second function, LogReceivedMessages, is skipped/not triggered?
Are this as it should? Or are the try and catch in your implementation wrongly situated!? Unsure how this works in the MQTTnet implementation ...
Thx in advance for answering!
Beta Was this translation helpful? Give feedback.
All reactions