CoAP 协议插件

emqx_coap CoAP 协议插件 - 图1 (opens new window) 提供对 CoAP 协议(RFC 7252)的支持。

配置 CoAP 协议插件

etc/plugins/emqx_coap.conf:

  1. coap.port = 5683
  2. coap.keepalive = 120s
  3. coap.enable_stats = off

若开启以下配置,则可以支持 DTLS:

  1. ## DTLS 监听端口
  2. coap.dtls.port = 5684
  3. coap.dtls.keyfile = /certs/key.pem
  4. coap.dtls.certfile = /certs/cert.pem
  5. ## 双向认证相关
  6. ## coap.dtls.verify = verify_peer
  7. ## coap.dtls.cacertfile = /certs/cacert.pem
  8. ## coap.dtls.fail_if_no_peer_cert = false

测试 CoAP 插件

我们可以通过安装 libcoap CoAP 协议插件 - 图2 (opens new window) 来测试 EMQ X 对 CoAP 协议的支持情况。

  1. yum install libcoap
  2. % coap client publish message
  3. coap-client -m put -e "qos=0&retain=0&message=payload&topic=hello" coap://localhost/mqtt