项目作者: VolantMQ

项目描述 :
High-Performance MQTT Server
高级语言: Go
项目地址: git://github.com/VolantMQ/volantmq.git
创建时间: 2017-05-17T14:13:44Z
项目社区:https://github.com/VolantMQ/volantmq

开源协议:Apache License 2.0

下载


VolantMQ

CircleCI
Codacy Badge
codecov.io
License

VolantMQ image
VolantMQ image by *Marina Troian, licensed under [Creative Commons Attribution 4.0 International License][cc-by]

VolantMQ is a high performance MQTT broker that aims to be fully compliant with MQTT specs

Features

MQTT Specs

Network Transports

  • TCP
  • TLS
  • WebSocket
  • WebSocket+TLS

Persistence

By default server starts with in-memory persistence which means all sessions and messages lost after server restart.

Plugins

Auth

  • [x] Server built-in basic auth.Key-value pairs in format user: sha256 of password provided by any of the following options

    • Users and their password hashes in config file
      1. - name: internal # authenticator name, used by listeners
      2. backend: simpleAuth # authenticator type
      3. config:
      4. users:
      5. testuser: "9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05" # testpassword
    • Users and their password hashes in separate file
      1. - name: internal # authenticator name, used by listeners
      2. backend: simpleAuth # authenticator type
      3. config:
      4. users: # both can be used simultaneously
      5. testuser: "9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05" # testpassword
      6. usersFile: <some path>
  • [x] Build status HTTP

    Monitoring

  • Build status Systree
  • Build status Prometheus
  • In-Memory server built in
  • Build status BBolt

    Debug

  • Build status PProf

    Health

  • Build status Health

    Configuring

    Server starts with default config from here. Any further configurations applied on top

Environment variables

  • VOLANTMQ_CONFIG - path to configuration file described in this section.
  • VOLANTMQ_PLUGIN_AUTH_HTTP_<NAME>_TOKEN - API token for auth plugins
    For example to supply auth token into auth plugin http1 from config below variable should be declared as VOLANTMQ_PLUGIN_AUTH_HTTP_HTTP1_TOKEN

Config file

File divided in a few sections
Complete example can be found here

System

  1. system:
  2. log:
  3. console:
  4. level: info # available levels: debug, info, warn, error, dpanic, panic, fatal
  5. http:
  6. defaultPort: 8080 # default HTTP listener assigned. Assigned to plugins like debug/health/metrics if they dont specify own port

Plugins

  1. plugins:
  2. enabled: # list of plugins server will load on startup
  3. - systree
  4. - prometheus
  5. - debug
  6. - health
  7. - auth_http
  8. - persistence_bbolt
  9. config: # configuration of each plugin
  10. <plugin type>:
  11. - backed: systree # plugin name, allowed: systree, prometheus, http, prof.profiler, health, bbolt
  12. name: http1 # required by auth plugins only. Value used in auth.order
  13. config: # configuration passed to plugin on load stage. refer to particular plugin for configuration

Default auth config

  1. auth:
  2. order: # default auth order. Authenticators invoked in the order they present in the config. Listener can override
  3. - internal

MQTT specs

  1. mqtt:
  2. version: // list of supported MQTT specifications
  3. - v3.1.1
  4. - v5.0
  5. keepAlive:
  6. period: 60 # KeepAlive The number of seconds to keep the connection live if there's no data.
  7. # Default is 60 seconds
  8. force: false # Force connection to use server keep alive interval (MQTT 5.0 only)
  9. # Default is false
  10. options:
  11. connectTimeout: 10 # The number of seconds to wait for the CONNACK message before disconnecting.
  12. # If not set then default to 2 seconds.
  13. offlineQoS0: true # OfflineQoS0 tell server to either persist (true) or not persist (false) QoS 0 messages for non-clean sessions
  14. # If not set than default is false
  15. sessionPreempt: true # AllowDuplicates Either allow or deny replacing of existing session if there new client with same clientID
  16. # If not set than default is false
  17. retainAvail: true # don't set to use default
  18. subsOverlap: false # tells server how to handle overlapping subscriptions from within one client
  19. # - true server will send only one publish with max subscribed QoS even there are n subscriptions
  20. # - false server will send as many publishes as amount of subscriptions matching publish topic exists
  21. # Default is false
  22. subsId: false # don't set to use default
  23. subsShared: false # don't set to use default
  24. subsWildcard: true # don't set to use default
  25. receiveMax: 65535 # don't set to use default
  26. maxPacketSize: 268435455 # don't set to use default
  27. maxTopicAlias: 65535 # don't set to use default
  28. maxQoS: 2

Listeners

  1. listeners:
  2. defaultAddr: "0.0.0.0" # default 127.0.0.1
  3. mqtt: # there are two types of listeners allowed tcp and ws (aka WebSocket)
  4. tcp:
  5. 1883: # port number. can be as many ports configurations as needed
  6. host: 127.0.0.1 # optional. listen address. defaultAddr is used if omitted
  7. auth: # optional. default auth configuration is used if omitted
  8. order: # optional. default auth configuration is used if omitted
  9. - internal
  10. 1884:
  11. auth:
  12. order:
  13. - http1
  14. tls: # TLS configuration
  15. cert: # path to certificate file
  16. key: # path to key file
  17. ws:
  18. 8883:
  19. path: mqtt
  20. auth:
  21. order:
  22. - http1
  23. 8884:
  24. path: mqtt
  25. auth:
  26. order:
  27. - http1
  28. tls: # TLS configuration
  29. cert: # path to certificate file
  30. key: # path to key file

Reason to have multiple listeners comes from performance impact of TLS as well as authentication
Internal to system users can omit entire auth and TLS

  1. ┌──────────────┐
  2. MQTT process
  3. └───────▲──────┘
  4. ╔════════════════════════╗
  5. VolantMQ
  6. ╔════▼═══╗
  7. intranet◀═════════▶ 1883 # no auth, no TLS║
  8. ╚════════╝
  9. ╔════════╗
  10. internet◀═════════▶ 1884 # auth and TLS ║
  11. ╚═▲══▲══▲╝
  12. ╚════════════════════════╝
  13. ┌────┘ └───┐
  14. ┌──▼─┐ ┌──▼─┐ ┌─▼──┐
  15. IoT1 IoT2 IoTn
  16. └────┘ └────┘ └────┘

Distribution

  • Docker image contains prebuilt plugins listed in this [section][#Plugins]
  • Helm

How to use

  1. docker run --rm -p 1883:1883 -p 8080:8080 -v $(pwd)/examples/config.yaml:/etc/volantmq/config.yaml \
  2. --env VOLANTMQ_CONFIG=/etc/volantmq/config.yaml volantmq/volantmq

Contributing guidelines

Credits

This project is heavily inspired by surgemq. As it was unmaintained it was forked to here, redesigned and packed with features since then

Appreciate JetBrains for granted license