• Stars
    star
    126
  • Rank 284,640 (Top 6 %)
  • Language
    C
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NanoSDK - MQTT 5.0-compliant SDK with QUIC support in NNG flavor

Discord Twitter YouTube Community Build Status

NanoSDK C Client Library for the MQTT Protocol

This repository contains the source code for the NanoSDK MQTT C client library.

This project is a wrapping of the nanomsg-NNG(https://github.com/nanomsg/nng) nanomsg known as https://github.com/nanomsg/nanomsg[libnanomsg], and adds significant new capabilities like MQTT & QUIC while retaining compatibility with the original Scalability Protocols.

NOTE: In honor of NNG & Garrett(Creator & Maintainer), they are the cornerstone of NanoSDK. We respect all his contributions to the Open-Source world. And We create this repository only for tracking Issues/Discussions and fast-paced development while the MQTT support is missing in upstream.

Introduction & Rationale

NanoSDK is an open-source project jointly developed by EMQ and NNG. NanoSDK as a repository, it is maintained independently as the NNG version of NanoMQ (https://github.com/emqx/nanomq). At present, its master branch is a special version developed and optimized for MQTT workload and maintained independently, from which we have submitted several valuable PRs and Issues for NNG. Therefore, to make NanoMQ compatible with NNG's SP protocol, we are committed to adding MQTT 3.1.1/5.0 protocol support for NNG at here. So that the two kinds of protocols(MQTT and SP) can be used together with NanoSDK. This is also in accordance with the RoadMap direction previously formulated by NanoMQ team. According to the technical goals previously formulated with the NNG project maintainer - Garrett at the jointly open-source cooperation meeting, NNG will support ZeroMQ and MQTT 3.1.1/5.0 in the future. Before this really happens, this project will be maintained independently. The internal design of NanoSDK honors the programming style of the NNG framework and is compatible with the original SP protocol of NNG. At the same time, it does not affect the other features like HTTP/Websocket/TLS.

Advantages

Compared with other popular MQTT 3.1.1 SDK, NanoSDK has the following advantages:

  1. Fully asynchronous I/O and good SMP support NanoSDK based on NNG's asynchronous I/O, we implement the Actor-like programming model in C language. And managing to distribute the computation load among multiple CPU cores averagely.
  2. High compatibility and portability Inheriting the compatibility and easy portability of NNG, NanoSDK only relies on the native POSIX standard API and is friendly to various distributions of Linux. It can be migrated to any hardware and operating system platform easily.
  3. Support multiple API styles The programming style of the NNG framework comes with a high learning cost, and users need to have a deep understanding of the concept of AIO and Context. Therefore, we also prepared a traditional callback registration mechanism for users who are accustomed to using Paho and Mosquitto SDK. This not only reduces the programming difficulty but also reserves the advantages of NNG.
  4. High throughput & Low latency In NanoMQ's test report, its performance advantages of powerful high throughput and low latency have been reflected, and the direct successor of NanoMQ - the SDK also has excellent performance. It is cost-effective in terms of resources consumption. Unlike the traditional MQTT SDK which has only 1-2 threads, NanoSDK can make full use of system hardware resources to provide higher consumption throughput. In most IoT solutions based on EMQX, the backend service’s insufficient consuming capability always results in message congestion, which has always been a problem for open source developers. Especially for QoS 1/2 messages, most SDKs reply Ack for QoS 1/2 messages synchronously. NanoSDK provides asynchronous Ack capability under the premise of ensuring the QoS message sequence and message retransmission mechanism, which greatly improves the throughput and consumption capacity of QoS 1/2.

Inherited from NNG, NanoSDK is a performant & higly portable SDK. Which enable users create client application with high throughput.

This code builds libraries which enable applications to connect to an MQTT broker to publish messages, and to subscribe to topics and receive published messages.

For MQTT broker introduction, please refer to EMQX (https://github.com/emqx/emqx)

Information About MQTT

Libraries

The NanoSDK C client comprises four variant libraries, shared or static:

  • nng/demo/mqtt- simple mqtt client
  • nng/demo/mqtt_async - asynchronous MQTT client & command-linewith SSL/TLS (MQTTAsync)
  • nng/demo/mqttv5- simple mqttv5 client with async API
  • nng/demo/quic- simple MQTT over QUIC demo (Attention: MsQUIC needs to be installed)

API Documentation

The API documentation is provided in Asciidoc format in the docs/man subdirectory The <<docs/man/nng.7.adoc#,nng(7)>> page provides a conceptual overview and links to manuals for various patterns. The <<docs/man/libnng.3.adoc#,libnng(3)>> page is a good starting point for the API reference.

In addition, many users would like to add self-defined behavior in the callback of online and offline. Therefore, we modified the callback method of connection and disconnection to allow users to perform blocking and waiting operations in the callback without affecting the MQTT connection & pradigm itself, so as to improve the flexibility of NanoSDK. However, it should be noted that this will consume the number of threads inside the NanoSDK. If the taskq thread is exhausted, it will still affect the operation of the entire client. Please use it cautiously.

Building with CMake

git clone https://github.com/emqx/NanoSDK ; cd NanoSDK
git submodule update --init --recursive 
mkdir build && cd build
cmake -G Ninja ..
ninja

To enable Debug + ASAN

cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF ..

To enable MQTT over QUIC feature

cmake -G Ninja -DBUILD_SHARED_LIBS=OFF -DNNG_ENABLE_QUIC=ON ..

More Repositories

1

emqx

The most scalable open-source MQTT broker for IoT, IIoT, and connected vehicles
Erlang
13,975
star
2

MQTTX

A Powerful and All-in-One MQTT 5.0 client toolbox for Desktop, CLI and WebSocket.
TypeScript
3,843
star
3

CocoaMQTT

MQTT 5.0 client library for iOS and macOS written in Swift
Swift
1,589
star
4

neuron

Open source industrial IoT connectivity server
C
1,023
star
5

MQTT-Client-Examples

MQTT Client Examples
Kotlin
743
star
6

qmqtt

MQTT client for Qt
C++
693
star
7

emqtt-bench

Lightweight MQTT benchmark tool written in Erlang
Erlang
511
star
8

mqtt-jmeter

MQTT JMeter Plugin
Java
438
star
9

emqtt

Erlang MQTT 5.0 Client
Erlang
365
star
10

quic

QUIC protocol for Erlang & Elixir
Erlang
220
star
11

emqx-operator

A Kubernetes Operator for EMQX
Go
209
star
12

esockd

Erlang general non-blocking TCP/SSL socket server
Erlang
199
star
13

emqx-rel

Release Project for EMQX Broker prior to 4.3. Newer releases are built here: https://github.com/emqx/emqx
Shell
189
star
14

emqx-docs

EMQX product documentation
HTML
156
star
15

mria

Asynchronously replicated Mnesia-like database for Erlang/Elixir
Erlang
117
star
16

qmqtt-client

MQTT Client GUI Written with Qt
C++
97
star
17

ekka

Autocluster and Autoheal for EMQX Broker
Erlang
94
star
18

emqx-web-hook

EMQX Webhook Plugin
Erlang
79
star
19

emqx-rule-engine

EMQX Rule Engine
Erlang
69
star
20

emqx-plugin-template

EMQ X Plugin Template and Demo
Erlang
63
star
21

emqx-coap

EMQX CoAP Gateway
Erlang
61
star
22

emqx-auth-mysql

Authentication, ACL with MySQL Database
Erlang
55
star
23

emqx-dashboard

EMQ X Dashboard
CSS
52
star
24

MQTT-Web-Toolkit

EMQ Web Toolkit
Vue
44
star
25

emqx-extension-examples

Examples for ExHook & ExProto
Erlang
44
star
26

emqx-auth-http

EMQX HTTP Authentication/ACL Plugin
Erlang
43
star
27

emqx-dashboard5

The management console used to monitor and manage EMQX clusters.
Vue
42
star
28

neuron-dashboard

Neuron Dashboard
TypeScript
41
star
29

minirest

A Mini RESTful API Framework
Erlang
37
star
30

emqx-bridge-mqtt

Bridge of MQTT (deprecated since EMQX v5)
Erlang
37
star
31

replayq

Generic on-disk persistent queue implementation for Erlang
Erlang
35
star
32

emqx-auth-pgsql

EMQ X PostgreSQL Authentication Plugin
Erlang
35
star
33

edge-stack

Shell
34
star
34

emqx-auth-redis

EMQ X Redis Authentication/ACL Plugin
Erlang
33
star
35

hocon

HOCON configuration Parser for Erlang/OTP
Erlang
32
star
36

mqttbs

MQTT Benchmark Suite
32
star
37

mqtt5.0-cn

MQTT Version 5.0 Chinese
31
star
38

emqx-docker

An Open-Source, Cloud-Native, Distributed MQTT Message Broker for IoT.
Shell
30
star
39

emqx-lwm2m

EMQ X LwM2M Gateway
Erlang
30
star
40

emqx-sn

EMQX MQTT-SN Gateway
Erlang
29
star
41

emqx-auth-jwt

EMQ X JWT Authentication Plugin
Erlang
28
star
42

emqx-lua-hook

EMQ X Lua Hook
Erlang
28
star
43

ecpool

Erlang Connection/Client Pool Library
Erlang
28
star
44

emqx-exporter

Prometheus exporter for EMQX
Python
26
star
45

emqx-dashboard-frontend

EMQ X Dashboard Frontend
Vue
25
star
46

emqx-prometheus

EMQX Statsd
Erlang
24
star
47

emqx-exhook

The Multiple-Language extension plugin for EMQ X Hooks
Erlang
23
star
48

blog

EMQ Blog
Python
22
star
49

emqx-retainer

EMQ X Retainer
Erlang
21
star
50

emqx-auth-mongo

EMQ X Authentication/ACL with MongoDB
Erlang
21
star
51

coap-jmeter

CoAP JMeter Plugin
Java
20
star
52

eip

EMQX Improvement Proposals
Makefile
19
star
53

emqx-elixir-plugin

An Example Plugin for EMQX in Elixir
Elixir
19
star
54

emqx-exproto

The Multiple-Language extension plugin for Protocol access
Erlang
18
star
55

openai-mqtt-nodejs

Node.js project that combines OpenAI's API with MQTT for real-time AI-driven interactions in IoT ecosystems.
JavaScript
18
star
56

emqx-auth-username

EMQ X Authentication with Username and Password
Erlang
17
star
57

mqtt-to-timescaledb

Ingesting time series data into TimescaleDB using MQTT and EMQX | MQTT Timescale Integration
Makefile
16
star
58

erlang-rocksdb

Upstream is here: https://gitlab.com/barrel-db/erlang-rocksdb
C++
16
star
59

emqx-auth-clientid

EMQ X ClientId Authentication Plugin
Erlang
16
star
60

jq

jq (nif) for beam
C
15
star
61

emqx-dashboard-web

Frontend Source Code for EMQ X dashboard Enterprise v4
Vue
15
star
62

emqx-tutorial-cn

EMQ X 中文Tutorial
14
star
63

emqx-extension-java-sdk

The Java SDK for emqx-extension-hook
Java
14
star
64

emqttb

A scriptable autotuning load generator for MQTT
Erlang
14
star
65

neuron-docs

Neuron Documentation
Shell
14
star
66

emqx-extension-python-sdk

The Python SDK for emqx-extension-hook
Python
13
star
67

HBridge

High-performance MQTT Bridge written in Haskell
Haskell
12
star
68

cdk-emqx-cluster

Python
11
star
69

pulsar-client-erl

Apache Pulsar client for Erlang/Elixir
Erlang
11
star
70

emqx-management

EMQ X Management API
Erlang
10
star
71

wormhole

The channel for routing request from cloud to edge.
Go
10
star
72

local-storage-encryption

Obfuscate key-value pairs in localStorage.
JavaScript
10
star
73

deploy-emqx-to-aws-with-terraform

HCL
10
star
74

mqtt-to-kafka

Streaming IoT data into Confluent/Kafka using MQTT and EMQX | MQTT Kafka Integration
Makefile
10
star
75

emqx-ui

EMQX UI Library
Vue
9
star
76

cloud-docs

EMQX Cloud Documentations
CSS
9
star
77

emqx-meter-cn

EMQ X Meter Benchmark
Python
9
star
78

emqx-usage-example

Using Docker Compose to show different usages of EMQX
9
star
79

mqtt-to-influxdb

Ingesting time series data into InfluxDB using MQTT and EMQX | MQTT InfluxDB Integration
JavaScript
8
star
80

example

EMQ x IoT project sample code
Java
8
star
81

ehttpc

HTTP Client for Erlang/OTP
Erlang
7
star
82

mqtt-security-scanner

MQTT Security Scanner
Go
7
star
83

rebar3_emqx_plugin

A rebar3 plugin for automatically generate emqx plugin template
Erlang
7
star
84

ipqueue

High Performance Interleaved Priority Queue for Erlang/Elixir
Erlang
7
star
85

ecql

Erlang Cassandra CQL Driver
Erlang
7
star
86

deploy-emqx-to-alibabacloud-with-terraform

HCL
6
star
87

influxdb-client-erl

Erlang
6
star
88

lc

Load Control for beam
Erlang
6
star
89

emqx-recon

Recon debug/optimize plugin
Erlang
6
star
90

tf-emqx-performance-test

HCL
6
star
91

emqx-builder

Dockerfile
5
star
92

emqx-reloader

Erlang Module Reloader
Erlang
5
star
93

emqx-exproto-java-sdk

The Java SDK for emqx-exproto
Java
5
star
94

emqx-stomp

EMQ X Stomp Protocol Plugin
Erlang
5
star
95

emqx-webinars

Webinar materials
Shell
5
star
96

bootcamp

The learning center of EMQ products
C
5
star
97

mqtt-to-redis

Ingesting IoT data into Redis using MQTT and EMQX | MQTT Redis Integration
JavaScript
5
star
98

emqx-auth-ldap

EMQ X LDAP Authentication Plugin
Erlang
5
star
99

nanomq-docker

An ultra-lightweight and blazing-fast MQTT broker for IoT edge
Dockerfile
4
star
100

emqx-10million-test-cn

EMQ X 10MILLION TEST
4
star