First, we need to choose an MQTT server after understanding MQTT, under the official recommendation of MQTT to find the final choice to use EMQ to implement the server,EMQ what advantages can stand out in the official recommendation of so many server implementation, this chapter and we slowly understand the features of EMQ

Attach:

Meow a mi blog: W-blog. cnEMQ official address :emqtt.com/EMQ Chinese document :emqtt.com/docs/v2/gui…

1.EMQ

EMQ (Erlang/Enterprise/Elastic MQTT Broker) is based on the Erlang/OTP platform development of open source iot MQTT message server. Erlang/OTP is an excellent soft-realtime, low-latency, Distributed language platform. MQTT is a Lightweight, PubSub Internet of Things messaging protocol.

The design objective of EMQ project is to carry mass MQTT connections of mobile terminals or iot terminals, and to realize fast and low delay message routing among mass iot devices:

  • Stably hosts large-scale MQTT client connections, with a single server node supporting 500,000 to 1 million connections.
  • Distributed node cluster, fast and low latency message routing, single cluster supports 10 million routes.
  • Message server extension supports customized authentication and efficient storage of messages to back-end databases.
  • Full iot protocol support, MQTT, MQTT-SN, CoAP, WebSocket or proprietary protocol support.

When choosing a server, I consider the following points:

  • Ability to cluster to handle a large number of devices
  • Fine control of permissions (MQTT is publish and subscribe for both servers and terminals so permissions need to be restricted not everyone can send messages to the device)
  • Community improvement has the continuous support of the team
  • There is a visual dashboard management to monitor link state consumption

2. Install EMQ

The version used here is centos.7.4 (for other systems, please go to the official documentation to find the corresponding software package)

> yum -y install unzip > mkdir -p /app/install && cd /app/install > wget http://emqtt.com/static/brokers/emqttd-centos7-v2.3.5.zip > unzip emqttd centos7 - v2.3.5.zip && emqttd mv/usr/localCopy the code

Configure system environment variables

> vim /etc/profile

# emqtt
export EMQPATH=/usr/local/emqttd
export PATH=$EMQPATH/bin:$PATH

> source /etc/profileCopy the code

Check whether emQ is normal

> emqttd console ## Starting emqttd on node '[email protected]' emqttd CTL is starting... [ok] emqttd hook is starting... [ok] emqttd router is starting... [ok] emqttd pubsub is starting... [ok] emqttd stats is starting... [ok] emqttd metrics is starting... [ok] emqttd pooler is starting... [ok] emqttd trace is starting... [ok] emqttd client manager is starting... [ok] emqttd session manager is starting... [ok] emqttd session supervisor is starting... [ok] emqttd wsclient supervisor is starting... [ok] emqttd broker is starting... [ok] emqttd alarm is starting... [ok] emqttd mod supervisor is starting... [ok] emqttd bridge supervisor is starting... [ok] emqttd access control is starting... [ok] emqttd system monitor is starting... [OK] EMqTTD 2.3.5 is running now Eshell V9.0 (abort with ^G) ([email protected])1> Load EMq_mod_presence module MQTT: TCP listen on 127.0.0.1:11883 with 4 Acceptors. MQTT: TCP listen on 0.0.0.0:1883 with 64 acceptors. MQTT :ws listen on 0.0.0.0:8083 with 4 acceptors MQTT: WSS listen on 0.0.0.0:8883 with 16 acceptors. MQTT: WSS listen on 0.0.0.0:8084 with 4 acceptors 0.0.0.0:8080 with 4 acceptors.Copy the code

Start the EMQ service

> emqttd start
emqttd 2.3.5 is started successfully!

> emqttd_ctl status
Node '[email protected]' is started
emqttd 2.3.5 is runningCopy the code

3. The use of EMQ

After we start EMQ, we can use the client to enter the link. The port is as follows

  • 1883 MQTT port
  • 8883 the MQTT/SSL port
  • MQTT/WebSocket port 8083
  • 8080 HTTP API port
  • 18083 Dashboard management console port

Access port 18083 using an IP address. You can view parameters such as EMQ running status online using the Dashboard

Default user: admin, password: public (users can be configured on the platform)

3 summary

At this point, EMQ is a bit of a scratch, but there is still some way to go before EMQ can be used to host millions of user connections. See you in the next section

Note: I have limited ability to say the wrong place hope we can point out, but also hope to communicate more!