question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MQTTnet.Exceptions.MqttProtocolViolationException: Received packet 'PubAck: [PacketIdentifier=21584] [ReasonCode=]' at an unexpected time.

See original GitHub issue

Describe the bug

A clear and concise description of what the bug is.

Which project is your bug related to?

  • [ √] ManagedClient

To Reproduce

An error occurred while connecting to the mqtt service。 This problem exists with the latest version or 2.8.5 Using TCP This error occurs when the program is running on Windows 7 sp1, but it is normal in Windows 10.

Additional context / logging

MQTTnet.Exceptions.MqttProtocolViolationException: Received packet ‘PubAck: [PacketIdentifier=21584] [ReasonCode=]’ at an unexpected time.

Code example

var options = new ManagedMqttClientOptionsBuilder()
		.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
		.WithClientOptions(new MqttClientOptionsBuilder()
			.WithClientId(Guid.NewGuid().ToString())                            
			.WithTcpServer("127.0.0.1", 33382)
			.WithCredentials(brokerInfo.BrokerUser, brokerInfo.BrokerPassword)
			.WithCleanSession()
			.Build())
		.Build();
var mqttClient = new MqttFactory().CreateManagedMqttClient();
mqttClient.StartAsync(options);               
mqttClient.ConnectingFailedHandler = new FailedHandler();                
mqttClient.ConnectedHandler = new ConnectedHandler(lblWsState);

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chkr1011commented, Jan 7, 2021

I will add some checks that a PUBREC from a previous connection will no longer throw this exception. I will check if a PUBREL can be sent indicating that the client doesn’t know the message anymore.

1reaction
SeppPennercommented, Jul 29, 2019

@Doyle-net Does this mean you fixed this issue and if yes how?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Received packet 'PubAck: [PacketIdentifier=21584] ...
This error occurs when the program is running on Windows 7 sp1, but it is normal in Windows 10. Additional context / logging....
Read more >
MQTTnet
MQTTnet.Exceptions.MqttProtocolViolationException: Received packet 'PubAck: [PacketIdentifier=21584] [ReasonCode=]' at an unexpected time. $ 0.
Read more >
MQTT 5.0 Message delivery retry and reason code
In MQTT 5.0 specification, it states that 'If PUBACK or PUBREC is received containing a Reason Code of 0x80 or greater the corresponding...
Read more >
MQTT Reason Code Introduction and Quick Reference - EMQ
Reason Code Name Packets 0x00 Normal disconnection DISCONNECT 0x00 Granted QoS 0 SUBACK 0x01 Granted QoS 1 SUBACK
Read more >
MQTT - AWS IoT Core
When the device reconnects to a persistent session, the session resumes, subscriptions are reinstated, and unacknowledged subscribed messages received and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found