NotSupportedException: Extended authentication handler is not yet supported
Describe the bug
While connecting to emqx we often get the "Extended authentication handler is not yet supported" exception. My library automatically retries after 500ms and it eventually successfully connects. Of course, no setting is being changed in between the retries.
Which component is your bug related to?
- Client
To Reproduce
Steps to reproduce the behavior:
- Using MQTTnet 4.2.1.781
- Try to connect to EMQX from a couple of pods running on AWS EKS.
- The first try often fails with a
NotSupportedException(Extended authentication handler is not yet supported)
Expected behavior
The connection always succeeds.
Additional context / logging
This is the exception we get:
MQTTnet.Adapter.MqttConnectingFailedException: Error while authenticating. Extended authentication handler is not yet supported
---> System.NotSupportedException: Extended authentication handler is not yet supported
at MQTTnet.Client.MqttClient.Authenticate(IMqttChannelAdapter channelAdapter, MqttClientOptions options, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at MQTTnet.Client.MqttClient.Authenticate(IMqttChannelAdapter channelAdapter, MqttClientOptions options, CancellationToken cancellationToken)
at MQTTnet.Client.MqttClient.ConnectInternal(IMqttChannelAdapter channelAdapter, CancellationToken cancellationToken)
at MQTTnet.Client.MqttClient.ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken)
at MQTTnet.Client.MqttClient.ConnectAsync(MqttClientOptions options, CancellationToken cancellationToken)
at Silverback.Messaging.Broker.Mqtt.MqttClientWrapper.TryConnectClientAsync(Boolean isFirstTry, CancellationToken cancellationToken)
It's not thrown for all clients instantiated within the same application and not always for the same ones.
Code example
The actual code uses Silverback, which wraps MQTTnet. The resulting MQTTnet related code is something like this:
IMqttClient mqttClient = MqttFactory.CreateClient();
await mqttClient.ConnectAsync(options, cancellationToken);
The options passed look like this:
{MQTTnet.Client.MqttClientOptions}
AllowPacketFragmentation: true
AuthenticationData: null
AuthenticationMethod: null
ChannelOptions: {mqtt:1883}
CleanSession: true
ClientId: "Xyz_Xyz_9a3c0f23-70e7-43f2-b266-907fafb19371"
Credentials: {MQTTnet.Client.MqttClientCredentials}
ExtendedAuthenticationExchangeHandler: null
KeepAlivePeriod: {00:00:15}
MaximumPacketSize: 0
ProtocolVersion: V500
ReceiveMaximum: 0
RequestProblemInformation: true
RequestResponseInformation: false
SessionExpiryInterval: 0
ThrowOnNonSuccessfulConnectResponse: true
Timeout: {00:01:40}
TopicAliasMaximum: 0
TryPrivate: true
UserProperties: {Count = 0}
ValidateFeatures: true
WillContentType: null
WillCorrelationData: null
WillDelayInterval: 0
WillMessageExpiryInterval: 0
WillPayload: null
WillPayloadFormatIndicator: Unspecified
WillQualityOfServiceLevel: AtMostOnce
WillResponseTopic: null
WillRetain: false
WillTopic: null
WillUserProperties: {Count = 0}
WriterBufferSize: 4096
WriterBufferSizeMax: 65535
The guid in the ClientId is the Kubernetes pod id.
This is related to issue #2095. That issue is closed and resolved with pull request #2132. This issue possibly can be closed as enhanced authentication (previously called extended authentication in the v4 library) is now properly supported as of the v5 release.