dotnet / dotnet/MQTTnet

Client Receiving Rate

Open
#1,861 5 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C#
Stars
5.1k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

Hi there , i am try to achieve best performance while receiving messages from server.
i want'to know how many messages received in regular client per/second.

My Setup,
-EMQX Broker Inside Docker
-Net Core 6.0 Console App with 4.3.1.873 MQTTNet Nuget Library
-https://github.com/inovex/mqtt-stresser - MQTT Stress Tester App
-İ7 1265U CPU / 32G memory , MQTTNET Application Running in Release Mode

I'am running Inovex Strees Tester with these parameters ,

`docker run --rm inovex/mqtt-stresser -broker tcp://emqx:1883 -username admin -password public -num-clients 200 -num-messages 250 -rampup-delay 0s -rampup-size 200 -global-timeout 180s -timeout 2s -publisher-qos 2`

And this is my net core Implementation

```
var factory = new MqttFactory();

int cnt = 0;
var mqttClient = factory.CreateMqttClient();
var options = new MqttClientOptionsBuilder()
.WithClientId(Guid.NewGuid().ToString())
.WithTcpServer("localhost", 1883)
.WithCredentials("admin", "public")
.Build();

var list = new List();
list.Add(new MqttTopicFilter { Topic = "#" });
await mqttClient.ConnectAsync(options);

await mqttClient.SubscribeAsync(new MqttClientSubscribeOptions()
{
TopicFilters = list,

});

Stopwatch sw = new Stopwatch();
mqttClient.ApplicationMessageReceivedAsync += async e =>
{
if (!e.ApplicationMessage.Topic.Contains('$'))
{
Interlocked.Increment(ref cnt);
if (cnt == 1) { sw.Start(); }
if (cnt == 50000)
{
sw.Stop();
cnt = 0;
await Console.Out.WriteLineAsync(sw.Elapsed.TotalSeconds.ToString());
sw.Reset();

}
}
};
Console.ReadLine();
```

This is Inovex Output

![image](https://github.com/dotnet/MQTTnet/assets/3975634/64137eca-0edc-4fdd-8e6a-4c60002f26cb)

And MQTTNet Client Says - 50K Messages Received in 1.45 / Sec
![image](https://github.com/dotnet/MQTTnet/assets/3975634/a8a6acd3-6179-41cc-bd3d-c71efdd03d3d)

### Which project is your question related to?
- Client
- Generic

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.