run time failure with Mqtt client.connect

0

The C# program (on win10 laptop) is publishing to the Mosquitto server (on Ubuntu laptop) every 1 second. Both laptops are connected by Wifi, on same local network. It is working well. Mostly.

After every ~500 cycles, a run time error occurs:

uPLibrary.Networking.M2Mqtt.Exceptions.MqttConnectionException HResult=0x80131500 Message=Exception connecting to the broker Source=M2Mqtt.Net

The code that generated the error:

        MqttClient client = new MqttClient(IP_ADDR);           
        byte code = client.Connect(new Guid().ToString(), null, null, true, 10);
        if (code==0)
        { .......

I can understand that connection may fail, yet I would expect the return code to be a non zero value in such a case, and not a run time exception. I know I can put in a "TRY" , yet I wonder how can I solve it in a better way.

Thank you

c#
runtime-error
client
mqtt
mosquitto
asked on Stack Overflow Jun 7, 2020 by YigalB

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0