-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
订阅高并发topic场景会存在内存泄漏 #1947
Comments
// See https://aka.ms/new-console-template for more information
using MQTTnet;
using MQTTnet.Client;
Console.WriteLine("Hello, World!");
var mqttFactory = new MqttFactory();
var mqttClient = mqttFactory.CreateMqttClient();
var mqttClientOptions = new MqttClientOptionsBuilder()
.WithTcpServer("10.132.105.8")
.WithClientId("ebb46a457522466882bdb6d316fa29f3")
.Build();
// Setup message handling before connecting so that queued messages
// are also handled properly. When there is no event handler attached all
// received messages get lost.
mqttClient.ApplicationMessageReceivedAsync += e =>
{
Console.WriteLine("Received application message.");
Thread.Sleep(500);
return Task.CompletedTask;
};
await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);
var mqttSubscribeOptions = mqttFactory.CreateSubscribeOptionsBuilder()
.WithTopicFilter(
f =>
{
f.WithTopic("/iothub/#");
})
.Build();
await mqttClient.SubscribeAsync(mqttSubscribeOptions, CancellationToken.None);
Console.ReadLine(); topic: /iothub/a |
Google Translate: 'Das Abonnieren von Themenszenarien mit hoher Parallelität kann zu Speicherverlusten führen' |
@colincodefirst First I would suggest to replace Thread.Sleep(500); with await Task.Delay(TimeSpan.FromMilliseconds(500)); |
I agree, the rest of the code looks good for me. |
Verification
The text was updated successfully, but these errors were encountered: