In my current .NET-project I want to publish a message over MQTT to a broker, but I tried several ways to implement this, but none of them works. I would like to use M2Mqtt (Paho Link), but I also tried MqttDotNet with no success.
My current way to solve this problem is to get the easiest possible implementation to work, but even this one does not work. I'm just creating an instance of MqttClient, connect to the broker (debugging shows me this works via 'IsConnected') and then I publish a message (simple string 'Local:0:user:dev'). Nevertheless my broker never receives this message and the only reaction I'm getting from VisualStudio are these 4 lines:
Der Thread 0x13a8 hat mit Code 259 (0x103) geendet. Der Thread 0x16d4 hat mit Code 259 (0x103) geendet. Der Thread 0x1ab0 hat mit Code 259 (0x103) geendet. Der Thread 0xa48 hat mit Code 259 (0x103) geendet.
This message is german and it is identical with the thread exiting message mentioned here.
I'm using this code to connect, publish and disconnect and I already tried the same code without the 'disconnect'-part.
MqttClient client = new MqttClient("127.0.0.1");
client.Connect("client");
client.Publish("cdj/new", Encoding.UTF8.GetBytes(message));
client.Disconnect();
Just to make sure, the broker is working and it can receive exactly the same message sent via Paho MQTT Utility. I'm using .NET 4.0 and also M2Mqtt version 4.0 (because the newest version is for .NET 4.5).
I don't know what I should do different, especially because there is no exeption or error message indicating what is going wrong there.