Program needs to have the ability to unsubscribe from topics and disconnect from broker entirely. Cannot seem to do either.
When doing the unsubscribe - nothing is done - I check the broker and the topics are still subscribed to by the client. Have the unsubscribe event registered in the connect but do not get anything back method so the client is not unsubscribing from the topic.
Method Code posted below - as well as the Client Disconnect exception thrown each time I try to disconnect.
public void disconnectFromMQTT(List Topics)
{
foreach (string t in Topics)
{
try
{
myClient.Unsubscribe(new [] { t });
}
catch(Exception e)
{
System.Windows.MessageBox.Show(Convert.ToString(e));
}
}
try
{
myClient.Disconnect();
}
catch(Exception e)
{
System.Windows.MessageBox.Show(Convert.ToString(e));
}
}
Exception Thrown -
Exception thrown: 'uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException' in M2Mqtt.Net.dll
uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException ---> System.NullReferenceException: Object reference not set to an instance of an object.
at uPLibrary.Networking.M2Mqtt.MqttNetworkChannel.Send(Byte[] buffer) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\Net\MqttNetworkChannel.cs:line 283
at uPLibrary.Networking.M2Mqtt.MqttClient.Send(Byte[] msgBytes) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1002
--- End of inner exception stack trace ---
at uPLibrary.Networking.M2Mqtt.MqttClient.Send(Byte[] msgBytes) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1015
at uPLibrary.Networking.M2Mqtt.MqttClient.Send(MqttMsgBase msg) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1026
at uPLibrary.Networking.M2Mqtt.MqttClient.Disconnect() in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 610
at MyHomeAuto.MQTT.disconnectFromMQTT(List`1 Topics) in G:\C#\Personal Programs\MyHomeAuto\MyHomeAuto\Classes\MQTT\MQTT.cs:line 86
Program needs to have the ability to unsubscribe from topics and disconnect from broker entirely. Cannot seem to do either.
When doing the unsubscribe - nothing is done - I check the broker and the topics are still subscribed to by the client. Have the unsubscribe event registered in the connect but do not get anything back method so the client is not unsubscribing from the topic.
Method Code posted below - as well as the Client Disconnect exception thrown each time I try to disconnect.
public void disconnectFromMQTT(List Topics)
{
Exception Thrown -
Exception thrown: 'uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException' in M2Mqtt.Net.dll uPLibrary.Networking.M2Mqtt.Exceptions.MqttCommunicationException ---> System.NullReferenceException: Object reference not set to an instance of an object. at uPLibrary.Networking.M2Mqtt.MqttNetworkChannel.Send(Byte[] buffer) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\Net\MqttNetworkChannel.cs:line 283 at uPLibrary.Networking.M2Mqtt.MqttClient.Send(Byte[] msgBytes) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1002 --- End of inner exception stack trace --- at uPLibrary.Networking.M2Mqtt.MqttClient.Send(Byte[] msgBytes) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1015 at uPLibrary.Networking.M2Mqtt.MqttClient.Send(MqttMsgBase msg) in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 1026 at uPLibrary.Networking.M2Mqtt.MqttClient.Disconnect() in c:\Users\ppatierno\Source\Repos\m2mqtt\M2Mqtt\MqttClient.cs:line 610 at MyHomeAuto.MQTT.disconnectFromMQTT(List`1 Topics) in G:\C#\Personal Programs\MyHomeAuto\MyHomeAuto\Classes\MQTT\MQTT.cs:line 86