I have recently started learning to work on various communication protocols for IoT. Given below is the line of code I can't get my head around.I try to run the code:
MqttClient Client = new MqttClient(Broker, ClientId, Persistence);
But shows an "Unhandled exception" error. So I fixed it by enclosing it with a try/catch.
try {
MqttClient Client = new MqttClient(Broker, ClientId, Persistence);
} catch (MqttException e) {
e.printStackTrace();
}
It actually works but can't understand why the need of this. Thanks in advance.