Mqtt Client TLS 1.3

Unable to implement tls 1.3 in c# using MQTTnet client.

Broker : Hivemq

Can anyone help with implementation in c#?


Hi @Rahul,

so I think the solution is the MqttClientOptionsBuilder, there you can set the TLS version:

var mqttFactory = new MqttFactory();

        using (var mqttClient = mqttFactory.CreateMqttClient())
            var mqttClientOptions = new MqttClientOptionsBuilder().WithTcpServer("", 8883)
                    o =>
                        o.SslProtocol = SslProtocols.Tls13; //set tls version

            // In MQTTv5 the response contains much more information.
            var response = await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);

            Console.WriteLine("The MQTT client is connected.");


Michael from the HiveMQ team