NetPro.MQTTClient
6.0.3-beta.5
This is a prerelease version of NetPro.MQTTClient.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package NetPro.MQTTClient --version 6.0.3-beta.5
NuGet\Install-Package NetPro.MQTTClient -Version 6.0.3-beta.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NetPro.MQTTClient" Version="6.0.3-beta.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NetPro.MQTTClient --version 6.0.3-beta.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NetPro.MQTTClient, 6.0.3-beta.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NetPro.MQTTClient as a Cake Addin #addin nuget:?package=NetPro.MQTTClient&version=6.0.3-beta.5&prerelease // Install NetPro.MQTTClient as a Cake Tool #tool nuget:?package=NetPro.MQTTClient&version=6.0.3-beta.5&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NetPro.MQTTClient 使用
MQTT客户端类库,支持多服务端,完整示例
使用
安装引用NetPro.MQTTClient
先增加如下配置
"MQTTClientOption": {
"Enabled": true,
"ConnectionString": [
{
"Key": "1", //连接串key别名,唯一
"Value": "clientid=netpro;host=mqtt://127.0.0.1:1883;username=netpro;password=netpro;timeout=5000;keepalive=120;cleansession=true;" //别名key对应的连接串
}
]
}
1、基于NetPro.Startup基座
增加环境变量 ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=NetPro.Satrtup
2、无依赖使用
public void ConfigureServices(IServiceCollection services)
{
services.AddMQTTClient(configuration);
}
服务注入使用
public class HttpProxyController : ControllerBase
{
private readonly ILogger _logger;
private readonly MqttClientMulti _mqttClientMulti;
//构造函数注入
public HttpProxyController(
ILogger<DatabaseCurdController> logger
MqttClientMulti _mqttClientMulti)
{
_logger = logger;
_exampleProxy = exampleProxy;
}
[HttpGet("getorcreate")]
[PostResponseCache(Duration = 2)]
[ProducesResponseType(200, Type = typeof(ResponseResult))]
public async Task<IActionResult> GetOrCreateAsync(uint id)
{
var _mqttClient = _mqttClientMulti["1"];
var messagePayload = new MqttApplicationMessageBuilder()
.WithTopic("netpro/local")//共享标识$queue和$share
.WithPayload($"发布消息-{DateTime.Now}")
.WithAtMostOnceQoS()//WithAtMostOnceQoS:Level0ithAtLeastOnceQoS:Level1;WithExactlyOnceQoS:Level2
.WithRetainFlag(true)//服务器保持消息,有客户端连接此主题后一条消息;一个主题保留一条消息;
.Build(); //删除消息既发送一条Payload为0的消息即可。
_mqttPublishClient.PublishAsync(messagePayload);
return Ok();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- MQTTnet (>= 3.1.1)
- NetPro.Core (>= 6.0.3-beta.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.0.16 | 204 | 7/24/2023 |
6.0.15 | 435 | 7/19/2022 |
6.0.14 | 421 | 7/10/2022 |
6.0.13 | 437 | 6/15/2022 |
6.0.12 | 422 | 6/15/2022 |
6.0.11 | 423 | 6/15/2022 |
6.0.10 | 429 | 6/11/2022 |
6.0.9 | 436 | 6/8/2022 |
6.0.8 | 435 | 5/26/2022 |
6.0.8-beta.3 | 149 | 5/24/2022 |
6.0.8-beta.2 | 123 | 5/24/2022 |
6.0.7 | 445 | 5/18/2022 |
6.0.6 | 459 | 4/28/2022 |
6.0.5 | 436 | 3/30/2022 |
6.0.5-beta.20 | 119 | 4/27/2022 |
6.0.5-beta.19 | 126 | 4/25/2022 |
6.0.5-beta.18 | 120 | 4/22/2022 |
6.0.5-beta.17 | 126 | 4/16/2022 |
6.0.5-beta.16 | 190 | 4/8/2022 |
6.0.5-beta.15 | 125 | 4/8/2022 |
6.0.5-beta.14 | 136 | 4/7/2022 |
6.0.5-beta.13 | 137 | 4/7/2022 |
6.0.5-beta.12 | 126 | 4/6/2022 |
6.0.5-beta.11 | 127 | 4/6/2022 |
6.0.5-beta.10 | 129 | 3/31/2022 |
6.0.5-beta.9 | 133 | 3/26/2022 |
6.0.5-beta.8 | 133 | 3/22/2022 |
6.0.5-beta.7 | 124 | 3/21/2022 |
6.0.5-beta.6 | 135 | 3/14/2022 |
6.0.5-beta.5 | 130 | 3/2/2022 |
6.0.5-beta.4 | 128 | 2/22/2022 |
6.0.5-beta.3 | 136 | 2/18/2022 |
6.0.5-beta.2 | 130 | 2/18/2022 |
6.0.5-beta.1 | 132 | 2/16/2022 |
6.0.4 | 465 | 2/10/2022 |
6.0.3 | 459 | 2/9/2022 |
6.0.3-beta.9 | 133 | 2/10/2022 |
6.0.3-beta.7 | 150 | 1/27/2022 |
6.0.3-beta.6 | 157 | 1/19/2022 |
6.0.3-beta.5 | 145 | 1/17/2022 |
6.0.3-beta.4 | 149 | 1/16/2022 |
6.0.3-beta.3 | 146 | 1/14/2022 |
6.0.3-beta.2 | 135 | 1/13/2022 |
6.0.3-beta.1 | 171 | 1/11/2022 |
6.0.2 | 347 | 1/6/2022 |