当前位置:网站首页>Nanomq newsletter 2022-05 | release of V0.8.0, new webhook extension interface and connection authentication API

Nanomq newsletter 2022-05 | release of V0.8.0, new webhook extension interface and connection authentication API

2022-06-10 16:11:00 51CTO

NanoMQ It is edge oriented MQTT Message engine + Multi protocol message bus . Support MQTT The protocol and ZeroMQ and Nanomsg And other common bus protocols at different edges , Integrate broker and brokerless Message schema , It is convenient to build Internet of things edge computing applications .

Community station address :​ ​https://nanomq.io/zh​

GitHub Warehouse :​ ​https://github.com/emqx/nanomq​

NanoMQ The project keeps a small version every month + Steady iteration speed of an important new feature ,v0.8.0 It was officially released at the end of May ( Download address :​ ​https://github.com/emqx/nanomq/releases/tag/0.8.0​​). This time we bring you 2 Important feature updates :Event WebHook And can work with third parties HTTP API Integrated connection authentication interface . At the same time, it also added the View topic tree structure HTTP API, Various performance optimization and defect repair are also being continuously updated .

Efficient and easy-to-use edge WebHook System

WebHook yes EMQX A function loved by the majority of open source users ,NanoMQ It has also launched the same function to facilitate the integration of users with third-party edge computing applications .

NanoMQ Of WebHook System and EMQX In line , Use the same style of configuration .Webhook The default search path for the configuration file of is /etc/nanomq_web_hook.conf, You can also start by reading the configuration file through the command line . Specific configuration items can be viewed NanoMQ Docs :​ ​https://nanomq.io/docs/zh/latest/web-hook.html# Configuration item ​​ .

      
      
web.hook.enable=true
## Format example
web.hook.rule.<Event>.<Number>=<Rule>
  • 1.
  • 2.
  • 3.

Enable... In settings WebHook After function , You can configure triggering rules according to your needs , If it is necessary to match the client's online and offline events and all to ”webhook/msg/#” Messages of wildcard topics are forwarded to the corresponding HTTP API, The configuration method is as follows :

Trigger rule configuration

stay etc/nanomq_web_hook.conf Configurable trigger rules , The configuration format is as follows :

      
      
## Example
web.hook.enable=true
web.hook.url=http://127.0.0.1:8888
web.hook.headers.content-type=application/json
web.hook.body.encoding_of_payload_field=plain
web.hook.pool_size=32
web.hook.rule.client.connack.1={"action": "on_client_connack"}
web.hook.rule.client.disconnected.1={"action": "on_client_disconnected"}
web.hook.rule.message.publish.1={"action": "on_message_publish", "topic": "webhook/msg/#"}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

This setting will make NanoMQ Automatically capture and spit out the data of the client's online and offline and message publishing to the corresponding HTTP API 了 . at present HTTP An example of the requested data format is shown below :

      
      
## HTTP json Format example
Connack( The client connection success event ):
{
"proto_ver": 4,
"keepalive": 6 0,
"conn_ack": "success",
"username": "undefined",
"clientid": "nanomq-6ecb0b61",
"action": "client_connack"
}

Publish( News release ):
{
"ts": 1 6 5 0 6 0 9 2 6 7 0 0 0,
"topic": "webhook/msg/123",
"retain": false,
"qos": 0,
"action": "message_publish",
"from_username": "undefined",
"from_client_id": "nanomq-6ecb0b61",
"payload": "hello"
}

Disconnect( Client connection disconnection event ):
{
"reason": "normal",
"username": "undefined",
"clientid": "nanomq-6ecb0b61",
"action": "client_disconnected"
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.

at present NanoMQ Of WebHook The system supports the following events :

name

explain

Execution opportunity

client.connack

MQTT Client connection successful

When the server is ready to send the connection response message

client.disconnected

MQTT Client disconnected

When the client connection layer is ready to close

message.publish

MQTT News release

The server is publishing ( route ) Before news

If you need more information, please go to NanoMQ Project ​ ​Github page ​​ Submit function application Issue, We will arrange to add... As soon as possible .

It's important to note that ,NanoMQ Of WebHook The function is fully asynchronous operation , All matching event messages will pass through efficient internal IPC The channel enters a separate proprietary thread for processing , And Broker Functional isolation , It will not block the normal message flow in the original server , Very efficient and reliable .

NanoMQ Newsletter 2022-05|v0.8.0 Release , newly added WebHook Extended interface and connection authentication API_iot

About WebHook Specific configuration information and methods , And how to tune it. Please look forward to the next NanoMQ Series of tutorial articles .

HTTP Connection authentication API

HTTP Connection authentication is another common integration feature , It can easily integrate with the third-party authentication server to complete the connection request verification of the client . Another common open source project Mosquitto The plug-ins of the same type have been abandoned and are no longer maintained ,NanoMQ This function fills this gap , And it also maintains EMQX Same function and configuration style , Convenient for users .

Authentication rule configuration

Authentication HTTP API The configuration file reading method of the interface is the same as NanoMQ Other configuration files are the same . The internal configuration items include :

      
      
## Open or not HTTP Auth plug-in unit
## Value: true | false
auth.http.enable = true

## Auth Requested target HTTP URL
auth.http.auth_req.url = http://127.0.0.1:80/mqtt/auth

## HTTP Auth Request Request mode
## Value: post | get
auth.http.auth_req.method = post

## HTTP Request Headers for Auth Request
auth.http.auth_req.headers.content_type = application/x-www-form-urlencoded

## Parameters used to construct the request body or query string parameters
auth.http.auth_req.params = clientid=%c,username=%u,password=%P
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.

When the configuration is complete ,NanoMQ The client will be configured according to the request format Connect The package information request corresponds to HTTP URL. And judge whether to allow the client to connect successfully according to the return code (Code 200 It means success ). Please refer to the official website configuration document for more detailed configuration methods ​ ​https://nanomq.io/docs/en/latest/config-description.html#parameter-description​​.

Other function optimization and Bug Repair

Besides ,NanoMQ 0.8.0 There are also the following updates and optimizations :

  1. Correct the timestamp in the client's online and offline time messages timestamp Field is UNIX Standard timestamps , Before, it was the start timer .
  2. Revised NanoMQ How to use command line tools , Removed the default must use “start/stop” The limitation of .
  3. increase ZeroMQ Proxy message gateway documentation .
  4. Fixed the lock contention problem when the bridge connection is frequently closed by the remote end .
  5. Fixed the backlog caused by a large number of messages published by the client ,Sub The data contention problem caused by the sudden port of the client .
  6. The content of the last wish message will no longer be modified by default UTF-8 Check , Only when requested by the client .
  7. Fixed a problem using Retain As Published If the message attribute is empty, it will cause a crash .

Coming soon

NanoMQ The rule engine will be officially released next month , As well as the inclusion of new databases as full persistence options for edge data . This function is currently in Demo Stage , In the latest main branch, you can use . Users can compile, install and use by themselves , Welcome to have some fresh food :​ ​https://github.com/emqx/nanomq/​​ .

NanoSDK It will be released next month MQTT over QUIC Of RC edition , This is the industry's first based on C Full language support MQTT 3.1.1 and QUIC Functional MQTT SDK, Coming soon .

Copyright notice : This paper is about EMQ original , Reprint please indicate the source .

Link to the original text :​ ​https://www.emqx.com/zh/blog/nanomq-newsletter-202205​

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101532427371.html