All Projects → DrmagicE → Gmqtt

DrmagicE / Gmqtt

Licence: mit
Gmqtt is a flexible, high-performance MQTT broker library that fully implements the MQTT protocol V3.1.1 and V5 in golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Gmqtt

Iot Harbor
reactor3实现的mqtt库
Stars: ✭ 234 (-19.31%)
Mutual labels:  mqtt, mqtt-broker
Openremote
100% open-source IoT Platform - Integrate your assets, create rules, and visualize your data
Stars: ✭ 254 (-12.41%)
Mutual labels:  mqtt, mqtt-broker
Mosquitto Cluster
a built-in, autonomous Mosquitto Cluster implementation. MQTT集群.
Stars: ✭ 238 (-17.93%)
Mutual labels:  mqtt, mqtt-broker
Emqx Rel
The Release Project for EMQ X Broker
Stars: ✭ 166 (-42.76%)
Mutual labels:  mqtt, mqtt-broker
kafka-connect-iot-mqtt-connector-example
Internet of Things Integration Example => Apache Kafka + Kafka Connect + MQTT Connector + Sensor Data
Stars: ✭ 170 (-41.38%)
Mutual labels:  mqtt, mqtt-broker
Mqttnet
MQTTnet is a high performance .NET library for MQTT based communication. It provides a MQTT client and a MQTT server (broker). The implementation is based on the documentation from http://mqtt.org/.
Stars: ✭ 2,486 (+757.24%)
Mutual labels:  mqtt, mqtt-broker
tutorials.IoT-over-MQTT
📙 FIWARE 203: Provisioning Ultralight with an alternative transport: IoT over MQTT
Stars: ✭ 49 (-83.1%)
Mutual labels:  mqtt, mqtt-broker
Nanomq
Nano MQTT Broker - An Ultra-light and Blazing-fast MQTT Broker for IoT Edge
Stars: ✭ 104 (-64.14%)
Mutual labels:  mqtt, mqtt-broker
sol
Lightweight MQTT broker, written from scratch. IO is handled by a super simple event loop based upon the most common IO multiplexing implementations.
Stars: ✭ 72 (-75.17%)
Mutual labels:  mqtt, mqtt-broker
zmosq
MQTT/Mosquitto / ZeroMQ proxy
Stars: ✭ 22 (-92.41%)
Mutual labels:  mqtt, mqtt-broker
Mqtt Pwn
MQTT-PWN intends to be a one-stop-shop for IoT Broker penetration-testing and security assessment operations.
Stars: ✭ 156 (-46.21%)
Mutual labels:  mqtt, mqtt-broker
emqx-retainer
EMQ X Retainer
Stars: ✭ 19 (-93.45%)
Mutual labels:  mqtt, mqtt-broker
Crossbar
Crossbar.io - WAMP application router
Stars: ✭ 1,957 (+574.83%)
Mutual labels:  mqtt, server
Evmongoose
DEPRECATED. Evmongoose is an asynchronous, event(libev) based multi-protocol embedded networking library with functions including TCP, HTTP, WebSocket, MQTT and much more. It's based on mongoose and libev implementation and it's support Lua API.
Stars: ✭ 199 (-31.38%)
Mutual labels:  mqtt, server
Vertx Mqtt
Vert.x MQTT
Stars: ✭ 117 (-59.66%)
Mutual labels:  mqtt, server
mqttools
MQTT version 5.0 client and broker using asyncio
Stars: ✭ 44 (-84.83%)
Mutual labels:  mqtt, mqtt-broker
Server
Enterprise Open Source IM Solution
Stars: ✭ 53 (-81.72%)
Mutual labels:  mqtt, server
Mqtt
MQTT broker written in D, using vibe.d
Stars: ✭ 59 (-79.66%)
Mutual labels:  mqtt, mqtt-broker
channels-asgi-mqtt
Interface between MQTT and ASGI and Channels 2.0 compatible
Stars: ✭ 36 (-87.59%)
Mutual labels:  mqtt, mqtt-broker
lannister
A lightweight MQTT broker w/ full spec,Clustering,WebSocket,SSL written in Java
Stars: ✭ 20 (-93.1%)
Mutual labels:  mqtt, mqtt-broker

中文文档

Gmqtt Mentioned in Awesome Go Build Status codecov Go Report Card

News: Cluster mode is now supported, see federation plugin for examples and details.

Installation

$ go get -u github.com/DrmagicE/gmqtt

Features

  • Provide hook method to customized the broker behaviours(Authentication, ACL, etc..). See server/hooks.go for details
  • Support tls/ssl and websocket
  • Provide flexible plugable mechanism. See server/plugin.go and /plugin for details.
  • Provide Go interface for extensions to interact with the server. For examples, the extensions or plugins can publish message or add/remove subscription through function call. See Server interface in server/server.go and admin for details.
  • Provide metrics (by using Prometheus). (plugin: prometheus)
  • Provide GRPC and REST APIs to interact with server. (plugin:admin)
  • Provide session persistence which means the broker can retrieve the session data after restart. Currently, only redis backend is supported.
  • Provide clustering, see federation plugin for examples and details.

Get Started

The following command will start gmqtt broker with default configuration. The broker listens on 1883 for tcp server and 8883 for websocket server with admin and prometheus plugin loaded.

$ cd cmd/gmqttd
$ go run . start -c default_config.yml

configuration

Gmqtt use -c flag to define configuration path. If not set, gmqtt reads $HOME/gmqtt.yml as default. If default path not exist, Gmqtt will start with default configuration.

session persistence

Gmqtt uses memory to store session data by default and it is the recommended way because of the good performance. But the session data will be lose after the broker restart. You can use redis as backend storage to prevent data loss from restart:

persistence:
  type: redis  
  redis:
    # redis server address
    addr: "127.0.0.1:6379"
    # the maximum number of idle connections in the redis connection pool
    max_idle: 1000
    # the maximum number of connections allocated by the redis connection pool at a given time.
    # If zero, there is no limit on the number of connections in the pool.
    max_active: 0
    # the connection idle timeout, connection will be closed after remaining idle for this duration. If the value is zero, then idle connections are not closed
    idle_timeout: 240s
    password: ""
    # the number of the redis database
    database: 0

Authentication

Gmqtt provides a simple username/password authentication mechanism. (Provided by auth plugin). It is not enabled in default configuration, you can change the configuration to enable it:

# plugin loading orders
plugin_order:
  - auth
  - prometheus
  - admin

When auth plugin enabled, every clients need an account to get connected.You can add accounts through the HTTP API:

# Create: username = user1, password = user1pass
$ curl -X POST -d '{"password":"user1pass"}' 127.0.0.1:8083/v1/accounts/user1
{}
# Query
$ curl 127.0.0.1:8083/v1/accounts/user1
{"account":{"username":"user1","password":"20a0db53bc1881a7f739cd956b740039"}}

API Doc swagger

Docker

$ docker build -t gmqtt .
$ docker run -p 1883:1883 -p 8883:8883 -p 8082:8082 -p 8083:8083  -p 8084:8084  gmqtt

Documentation

godoc

Hooks

Gmqtt implements the following hooks:

Name hooking point possible usages
OnAccept When accepts a TCP connection.(Not supported in websocket) Connection rate limit, IP allow/block list.
OnStop When the broker exists
OnSubscribe When received a subscribe packet Subscribe access control, modifies subscriptions.
OnSubscribed When subscribe succeed
OnUnsubscribe When received a unsubscribe packet Unsubscribe access controls, modifies the topics that is going to unsubscribe.
OnUnsubscribed When unsubscribe succeed
OnMsgArrived When received a publish packet Publish access control, modifies message before delivery.
OnBasicAuth When received a connect packet without AuthMethod property Authentication
OnEnhancedAuth When received a connect packet with AuthMethod property (Only for v5 clients) Authentication
OnReAuth When received a auth packet (Only for v5 clients) Authentication
OnConnected When the client connected succeed
OnSessionCreated When creates a new session
OnSessionResumed When resumes from old session
OnSessionTerminated When session terminated
OnDelivered When a message is delivered to the client
OnClosed When the client is closed
OnMsgDropped When a message is dropped for some reasons
OnWillPublish When the client is going to deliver a will message Modify or drop the will message
OnWillPublished When a will message has been delivered

See /examples/hook for details.

How to write plugins

How to write plugins

Contributing

Contributions are always welcome, see Contribution Guide for a complete contributing guide.

Test

Unit Test

$ go test -race ./...

Integration Test

paho.mqtt.testing.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].