CPU Leak if you specify Username/password
malichishti opened this issue · 5 comments
Hi,
Im using M2MQTT from https://www.nuget.org/packages/M2Mqtt/
IF i create a client and specify a user name the CPU usgae goes up by 25% and stays there even if the connection fails due to wrong credentials. And next call to connect will increment the CPU usage by 25%
So if you have multiple thread connecting to MQTT server, after a couple of calls the CPU reached 100% and crashes.
Following code can reproduce the issue, add it to a Console application .Net 4.5 or greater:
Console.WriteLine("start?");
Console.Read();
Console.WriteLine("starting, please monitor the CPU usage.");
List < MqttClient > l = new List<MqttClient>();
for (int i = 0; i < 10; i++)
{
var client = new MqttClient(
"test.mosquitto.org"
, 1883
, false
, null
, null
, new MqttSslProtocols());
client.MqttMsgPublishReceived += Client_MqttMsgPublishReceived;
try
{
client.Connect(Guid.NewGuid().ToString(), "ss", null);//intentionally making it fail with wrong credentials
}
catch(Exception ex) { Console.WriteLine("Error"); }
l.Add(client);
}
Console.WriteLine("Exit?");
Console.Read();```
@malichishti I was able to fix my issue, lets me know if this fix yours.
I have the same experience, not only the CPU is high. but also that the Process cannot be aborted, process must be kill force
I have same problem.
Sad that this is still an issue in 2020.
same problem here but using certificates