MQTTnet
MQTTnet copied to clipboard
ActiveMQ broker returns PubAck (expecting CONNACK): [PacketIdentifier=21584] [ReasonCode=] error on Connect. Using ManagedMqttClient(MqttNet)
Describe your question
I'm connecting to AWS ActiveMQ broker (v5.15.12) using MQTTNet(v3.0.13-rc1) ManagedMqttClient(v3.0.12-rc1).
var client = new MqttFactory().CreateManagedMqttClient();
client.ConnectingFailedHandler = new ConnectingFailedHandlerDelegate((e) =>
{
throw e.Exception;
});
var optionsBuilder = new MqttClientOptionsBuilder();
optionsBuilder
.WithCleanSession()
.WithClientId(_clientId)
.WithTcpServer(_config.BrokerUrl, _config.Port)
.WithTls(new MqttClientOptionsBuilderTlsParameters()
{
AllowUntrustedCertificates = true,
IgnoreCertificateRevocationErrors = true,
CertificateValidationHandler = CertificateValidationCallback,
UseTls = true
})
.WithCredentials(_config.User, _config.Password);
optionsBuilder.WithWillMessage(new MqttApplicationMessage()
{
Retain = _wilPacket.Retain,
Topic = _wilPacket.Topic,
Payload = _wilPacket.Payload,
QualityOfServiceLevel = _qosLevel,
});
var clientOptionsBuilder = new ManagedMqttClientOptionsBuilder();
clientOptionsBuilder
.WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
.WithAutoReconnect()
.WithClientOptions(optionsBuilder.Build());
client.StartAsync(clientOptionsBuilder.Build());
But often in
client.ConnectingFailedHandler = new ConnectingFailedHandlerDelegate((e) =>
{
throw e.Exception;
});
get:
Received packet 'PubAck: [PacketIdentifier=21584] [ReasonCode=]' at an unexpected time.
response.
Most often this problem occurs when reconnecting or fast client restoring after crash
Is it relater to broker configuration or client connection configuration?
Any help will be appreciated.
In AWS CloudWatch Insights I can see warning
2020-10-13 04:00:01,236 | WARN | Transport Connection to: tcp://172.23.2.36:13854 failed: java.io.EOFException | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ Transport: ssl:///172.23.2.36:13854
Which project is your question related to?
- ManagedClient
looks like a problem in session takeover in AWS ActiveMQ broker. it is sending an acc that is meant for the old connection over the new connection
Closing this because the issue seems to be located in AWS ActiveMQ broker.