I am trying to write a POC using MQTTnet
and AWS IOT
. I can successfully connect and publish messages, but as soon as I subscribe the connection is closed with MqttClientDisconnectedException
- topic is "vin/my-vin"
- MQTTnet 4.2.1.781
- .NET 7 - console app
connect - works
var mqttFactory = new MqttFactory();
mqttClient = mqttFactory.CreateMqttClient();
var mqttClientOptions = new MqttClientOptionsBuilder()
.WithWebSocketServer(signedRequestUrl)
.Build();
await mqttClient.ConnectAsync(mqttClientOptions);
publish - works
var applicationMessage = new MqttApplicationMessageBuilder()
.WithTopic(topic)
.WithPayload("test")
.Build();
var resp = await mqttClient.PublishAsync(applicationMessage);
subscribe - fails with MqttClientDisconnectedException
var result = await mqttClient.SubscribeAsync(new MqttTopicFilterBuilder().WithTopic(topic).Build());
I've tried numerous different options when creating the client and calling subscribe, and the result is always the same
I believe another one of our devs has been able to get both publish and subscribe working in a web app with a javascript library, but I don't know the details (its the weekend)
MQTT is new to me so I might be missing something obvious. Any ideas what I'm doing wrong?