MQTTnet.Exception.MqttCommunicationTimeOutException
See original GitHub issueI met a MqttCommunicationTimeOutException, but I’m not sure what the problem, hope to be able to get help. Version 3.0.5 is used.
This is the exception information:
MQTTnet.Exceptions.MqttCommunicationTimedOutException: Exception of type 'MQTTnet.Exceptions.MqttCommunicationTimedOutException' was thrown.
at MQTTnet.PacketDispatcher.MqttPacketAwaiter`1.WaitOneAsync(TimeSpan timeout)
at MQTTnet.Client.MqttClient.SendAndReceiveAsync[TResponsePacket](MqttBasePacket requestPacket, CancellationToken cancellationToken)
at MQTTnet.Client.MqttClient.PublishAtLeastOnceAsync(MqttPublishPacket publishPacket, CancellationToken cancellationToken)
This is considered critical code:
MqttClient.UseApplicationMessageReceivedHandler(e =>
{
MqttClient_ApplicationMessageReceived(e);
});
private void MqttClient_ApplicationMessageReceived(MqttApplicationMessageReceivedEventArgs e)
{
Console.WriteLine("### 从服务端接收的消息 ###");
Console.WriteLine($"+ Topic = {e.ApplicationMessage.Topic}");
Console.WriteLine($"+ Payload = {Encoding.UTF8.GetString(e.ApplicationMessage.Payload)}");
Console.WriteLine();
// After processing, the theme is republished
Event_MQTTMessageReceived?.Invoke(e);
}
public void Publish(string topic, string Data)
{
if (MqttClient != null && MqttClient.IsConnected)
{
var _Message = new MqttApplicationMessageBuilder();
_Message.WithTopic(topic);
_Message.WithPayload(Data);
_Message.WithAtMostOnceQoS();
_Message.WithRetainFlag(false);
MqttClient.PublishAsync(_Message.Build());
Console.WriteLine("### 从本地发送的消息 ###");
Console.WriteLine($"+ Topic = {topic}");
Console.WriteLine($"+ Payload = {Data}");
Console.WriteLine();
}
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:10
Top Results From Across the Web
MQTTnet.Exception.MqttCommunicationTimeOutException
Version 3.0.5 is used. This is the exception information:. MQTTnet.Exceptions.MqttCommunicationTimedOutException: Exception of type 'MQTTnet.
Read more >c# - MQTTnet PublishAsync Exception
I'm trying to use "MQTTnet" in a Xamarin application. ... well, it publishs but after about 5 seconds it throw the following exception...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My question is solved. The cause is that client has possibility of unsubscribing topic after disconnected.
@chkr1011 I will re-open this.