Click here to Skip to main content
15,559,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created the console application which subscribes to multiple topics to the MQTT Broker. I have registered MqttMsgPublishedReceived even which triggers whenever there is a new data on the subscribed topic. The application is running properly for a single subscription. But when I tried to run the multiple subscriptions, the application is closing. How to make the MqttMsgPublisheReceived event to handle the multiple publishes. Below is my code snippet.
i followed following code
for(int i=0;i<client.Length;i++)


public void subscribe()



public void client_MqttPublishReceived(object sender,MqttMsgPublishEventargs e)


//business logic


MqttMsgPublishReceived event crashing for simulataneous messages. Thanks in advance

What I have tried:

I tried calling individually each topic.For which applcation properly. It is crashing whenever i run multiple applications.
Updated 8-Jun-18 2:35am

1 solution

This can't be answered based on the posted code because that is incomplete.

You should at least check for exceptions and report them to know where and when the application terminates and to get meaningful error messages. If that does not help you have to run it within a debugger.

Read also the documentation of the used functions and observe that some variables should be probably not shared by multiple subscriptions (use an array for those variables).
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900