CoAP 协议插件
emqx_coap (opens new window) 提供对 CoAP 协议(RFC 7252)的支持。
配置 CoAP 协议插件
etc/plugins/emqx_coap.conf:
coap.port = 5683
coap.keepalive = 120s
coap.enable_stats = off
若开启以下配置,则可以支持 DTLS:
## DTLS 监听端口
coap.dtls.port = 5684
coap.dtls.keyfile = /certs/key.pem
coap.dtls.certfile = /certs/cert.pem
## 双向认证相关
## coap.dtls.verify = verify_peer
## coap.dtls.cacertfile = /certs/cacert.pem
## coap.dtls.fail_if_no_peer_cert = false
测试 CoAP 插件
我们可以通过安装 libcoap (opens new window) 来测试 EMQ X 对 CoAP 协议的支持情况。
yum install libcoap
% coap client publish message
coap-client -m put -e "qos=0&retain=0&message=payload&topic=hello" coap://localhost/mqtt