Table of contents
foreword
The original link of this article is:
https://blog.csdn.net/freewebsys/article/details/108971807
fly-iot Feifan IoT column:
https://blog.csdn.net/freewebsys/category_12219758.html
Not to be reproduced without permission of the blogger.
The blogger’s CSDN address is: https://blog.csdn.net/freewebsys
The blogger’s nugget address is: https://juejin.cn/user/585379920479288
The blogger’s Zhihu address is: https://www.zhihu. com/people/freewebsystem
1. about
EMQX is an open source(opens new window) large-scale distributed MQTT message server with rich functions, designed for IoT and real-time communication applications. EMQX 5.0 single cluster supports up to 100 million MQTT concurrent connections, the transmission and processing throughput of a single server can reach millions of MQTT messages per second, and the latency is guaranteed to be at the sub-millisecond level.
EMQX supports multiple protocols, including MQTT (3.1, 3.1.1 and 5.0), HTTP, QUIC and WebSocket, etc., ensuring the accessibility of various network environments and hardware devices. EMQX also provides comprehensive SSL/TLS function support, such as two-way authentication and multiple authentication mechanisms, providing a reliable and efficient communication infrastructure for IoT devices and applications.
https://www.emqx.io/docs/zh/v5.1/
https://www.emqx.io/docs/zh/v5.1/deploy/install-docker.html
2. Use docker to deploy
Configuration account: admin
Password: public
Just use the latest version
docker run -d --name emqx -p 1883:1883 -p 8083:8083 -p 8084:8084 -p 8883:8883 -p 18083:18083 emqx/emqx:latest
port | illustrate |
---|---|
18083 | admin port of web management terminal |
1883 | Commonly used tcp ports |
8883 | ssl tcp port |
8083 | Commonly used websocket ports |
8084 | ssl websocket port |
You can ignore it, and then enter the management side.
3. Configure the API key that can be accessed using the interface
At this time, you can create another access API key:
http://127.0.0.1:18083/#/APIKey
Then put this configuration on arcorcloud:
Then create a device:
the password is: 11111111
4. Set client authentication and connect to PostgreSQL data connection
Set up client authentication:
This is the most important! !
Only as password and double quotes are required, which is a special way of writing PostgerSQL:
SELECT "token" as password FROM devices where
"deviceUsername" = ${username} LIMIT 1
The configuration was successful:
Client authentication is also possible :
You can also configure client authorization or turn off authorization:
SELECT 'allow' as action, 'all' as permission, 'all' as topic
FROM devices where "deviceUsername" = ${username}
5. Use the client to connect
The web page comes with a client, which can be connected directly.
This device is the device created in Actorcloud
6. API interface address of EMQX
EMQX also has a local swagger interface address:
http://localhost:18083/api-docs/index.html#
You can log in after setting the API username and password in the management terminal.
Then you can directly access:
the interface is very rich, you can directly access after authorization, and it is convenient to connect with other systems.
Secondary development has been carried out.
7. Summary
I finally figured it out, the use of EMQX also supports MQTT5, and I can connect to the devices created in the database normally.
At the same time, it supports many extension interfaces. It is very convenient to develop and connect the management side.
However, the callback interface currently does not know what job method to use to obtain the online status.
At the same time, there is an access status on actorcloud, which can be modified to:
-- 客户端认证
SELECT "token" as password FROM devices where
"deviceUsername" = ${username} AND "blocked" = 0
LIMIT 1
-- 客户端授权
SELECT 'allow' as action, 'all' as permission, 'all' as topic
FROM devices where "deviceUsername" = ${username} AND "blocked" = 0
Both are very good open source projects. In continuous research, the two projects are integrated and run, and the
actorcloud project and the Emqx project are deployed together.
The original link of this article is:
https://blog.csdn.net/freewebsys/article/details/108971807