dimohy
4์ 28, 2022, 12:06์คํ
1
dotnet/MQTTnet ์ MQTT ๊ธฐ๋ฐ ํต์ ์ ์ํ ๊ณ ์ฑ๋ฅ .NET ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก MQTT์ ์ทจ์ง์ ๋ง๊ฒ ๊ฒฝ๋์ด๋ฉฐ ์ด๋น 150,000๊ฐ ์์ค์ ๋ฉ์์ง๋ฅผ ์ฒ๋ฆฌํ๋ MQTT ํด๋ผ์ด์ธํธ ๋ฐ MQTT ์๋ฒ(๋ธ๋ก์ปค)๋ฅผ ์ ๊ณตํฉ๋๋ค.
Azure Functions MQTT ๋ฐ์ธ๋ฉ์ ์ฐ์ด๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ด๋ฉฐ .NET Foundation์์ ์ง์ํ๊ณ ์์ต๋๋ค.
MQTT ๋ ๋ฐํ-๊ตฌ๋
๊ธฐ๋ฐ์ ๋ฉ์์ง ํ๋กํ ์ฝ๋ก IoTํต์ ์ ๋ง์ด ์ฐ์
๋๋ค. ๊ณต๊ฐ๋ MQTT ๋ธ๋ก์ปค๊ฐ ๋ง์ด ์์ผ๋ฏ๋ก ๋ฉ์์ง ๊ธฐ๋ฅ์ ๊ฐ๋จํ๊ฒ ํ
์คํธํ๊ธฐ๋ ์ฉ์ํฉ๋๋ค.
MQTTNet์ ๋ค์์ ์ฃผ์ ํน์ง์ ๊ฐ์ง๊ณ ์์ต๋๋ค.
๋น๋๊ธฐ ์ง์
ํด๋ผ์ด์ธํธ ๋ฐ ์๋ฒ์ ๋ํ TLS ์ง์
ํ์ฅ ๊ฐ๋ฅํ ํต์ ์ฑ๋ (In-Memory, TCP, TCP+TLS, WS)
๊ฒฝ๋(์ค๋ฒํค๋ ์์)
์ฑ๋ฅ ์ต์ ํ(~150,000๊ฐ ๋ฉ์์ง/์ด ์ฒ๋ฆฌ)
์ง์๋๋ ๋ชจ๋ MQTT ํ๋กํ ์ฝ ๋ฒ์ ผ์ ๋ํ ๋์ผํ API ์ ๊ณต
๋ด๋ถ ์ถ์ ๋ฉ์์ง์ ๋ํ ์ก์ธ์ค
๋จ์ํ
์คํธ (~636 ํ
์คํธ)
์ธ๋ถ ์ข
์์ฑ ์์
ํนํ ์น์์ผ์ ์ง์ํ๊ธฐ ๋๋ฌธ์ ์น์์ผ์ ์ ๊ณตํ๋ ๋ธ๋ก์ปค๋ฅผ ์ด์ฉํด ์น๋ธ๋ผ์ฐ์ ์์๋ ํ์ฉํ ์ ์๋ ๋ฉ์์ง ํ๋กํ ์ฝ ์
๋๋ค.
5๊ฐ์ ์ข์์
dimohy
4์ 28, 2022, 1:01์คํ
2
๊นํ๋ธ์ Samples ๋ฅผ ํตํด ๊ฐ์ข
์ฌ์ฉ๋ฒ์ ํ์ตํ ์ ์์ต๋๋ค.
๋ค์์ broker.hivemq.com
MQTT ๋ธ๋ก์ปค์ ์ฐ๊ฒฐํ ํ ์ข
๋ฃํ๋ ์ฝ๋ ์
๋๋ค.
using MQTTnet;
using MQTTnet.Client.Options;
using System.Text.Json;
using MQTTnet.Client.Disconnecting;
var factory = new MqttFactory();
using var client = factory.CreateMqttClient();
var options = new MqttClientOptionsBuilder()
.WithTcpServer("broker.hivemq.com").Build();
var response = await client.ConnectAsync(options, CancellationToken.None);
var output = "NULL";
if (response != null)
{
output = JsonSerializer.Serialize(response, new JsonSerializerOptions
{
WriteIndented = true
});
}
Console.WriteLine($"[{response?.GetType().Name}]:\r\n{output}");
var disconnectOptions = new MqttClientDisconnectOptions();
await client.DisconnectAsync(disconnectOptions, CancellationToken.None);
MqttClientConnectResult]:
{
"ResultCode": 0,
"IsSessionPresent": false,
"WildcardSubscriptionAvailable": true,
"RetainAvailable": true,
"AssignedClientIdentifier": null,
"AuthenticationMethod": null,
"AuthenticationData": null,
"MaximumPacketSize": null,
"ReasonString": null,
"ReceiveMaximum": null,
"MaximumQoS": 0,
"ResponseInformation": null,
"TopicAliasMaximum": 0,
"ServerReference": null,
"ServerKeepAlive": null,
"SessionExpiryInterval": null,
"SubscriptionIdentifiersAvailable": false,
"SharedSubscriptionAvailable": false,
"UserProperties": null
}
์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ด์ฉํด ์๋ฒ ์์ด ์ ์ Blazor WASM์ผ๋ก ๊ฐ๋จํ๊ฒ ์ฑํ
ํ๋ก๊ทธ๋จ ์ํ์ ๋ง๋ค์ด๋ณผ ์์ ์
๋๋ค.
3๊ฐ์ ์ข์์