NetPro.MQTTClient 6.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetPro.MQTTClient --version 6.0.5
NuGet\Install-Package NetPro.MQTTClient -Version 6.0.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.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.5
#r "nuget: NetPro.MQTTClient, 6.0.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.5

// Install NetPro.MQTTClient as a Cake Tool
#tool nuget:?package=NetPro.MQTTClient&version=6.0.5

NetPro.MQTTClient 使用

NuGet

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  IMqttClientMulti _mqttClientMulti;
        //构造函数注入
        public HttpProxyController(
            ILogger<DatabaseCurdController> logger
            IMqttClientMulti _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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 160 7/24/2023
6.0.15 408 7/19/2022
6.0.14 401 7/10/2022
6.0.13 408 6/15/2022
6.0.12 395 6/15/2022
6.0.11 395 6/15/2022
6.0.10 402 6/11/2022
6.0.9 408 6/8/2022
6.0.8 409 5/26/2022
6.0.8-beta.3 134 5/24/2022
6.0.8-beta.2 111 5/24/2022
6.0.7 418 5/18/2022
6.0.6 433 4/28/2022
6.0.5 411 3/30/2022
6.0.5-beta.20 105 4/27/2022
6.0.5-beta.19 113 4/25/2022
6.0.5-beta.18 102 4/22/2022
6.0.5-beta.17 113 4/16/2022
6.0.5-beta.16 175 4/8/2022
6.0.5-beta.15 111 4/8/2022
6.0.5-beta.14 118 4/7/2022
6.0.5-beta.13 123 4/7/2022
6.0.5-beta.12 114 4/6/2022
6.0.5-beta.11 114 4/6/2022
6.0.5-beta.10 108 3/31/2022
6.0.5-beta.9 121 3/26/2022
6.0.5-beta.8 119 3/22/2022
6.0.5-beta.7 110 3/21/2022
6.0.5-beta.6 121 3/14/2022
6.0.5-beta.5 114 3/2/2022
6.0.5-beta.4 115 2/22/2022
6.0.5-beta.3 122 2/18/2022
6.0.5-beta.2 118 2/18/2022
6.0.5-beta.1 121 2/16/2022
6.0.4 437 2/10/2022
6.0.3 433 2/9/2022
6.0.3-beta.9 122 2/10/2022
6.0.3-beta.7 136 1/27/2022
6.0.3-beta.6 145 1/19/2022
6.0.3-beta.5 133 1/17/2022
6.0.3-beta.4 137 1/16/2022
6.0.3-beta.3 134 1/14/2022
6.0.3-beta.2 124 1/13/2022
6.0.3-beta.1 160 1/11/2022
6.0.2 322 1/6/2022