Resolved MqttCommunicationException: The client and server cannot communicate, because they do not possess a common algorithm
var factory = new MqttFactory();
var client = factory.CreateMqttClient();
var options = new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid().ToString())
.WithTcpServer(config["HostName"], int.Parse(config["PortNumber"]))
.WithCredentials(config["UserName"], config["Password"])
.WithTls(new MqttClientOptionsBuilderTlsParameters()
{
UseTls = true,
SslProtocol = SslProtocols.Tls12
})
.WithCleanSession()
.Build();
client.ConnectAsync(options).Wait();