emqtt:Erlang MQTT v5.0客户端

  • h3_540027
    了解作者
  • 873.6KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-13 18:55
    上传日期
Emqtt 在Erlang中实现的MQTT客户端库和命令行工具,支持MQTT v5.0 / 3.1.1 / 3.1。 入门 作为命令行工具 建造 $ make 成功编译后,您将在_buile/emqtt/rel/emqtt/bin获得一个名为emqtt的脚本。 我们可以看到emqtt使用--help选项可以做什么: $ ./emqtt --help Usage: emqtt pub | sub [--help] emqtt pub用于发布有关主题的单个消息并退出。 emqtt sub用于订阅主题并打印其接收的消息。 命令行语法 选项可以同时具有短(单个字符)和长(字符串)选项名称。 简短选项可以具有以下语法: -e arg Single option 'e', argument "arg" 长选项可以具有以下语法: --example=arg Single op
emqtt-master.zip
内容介绍
# emqtt MQTT client library and command line tools implemented in Erlang that supports MQTT v5.0/3.1.1/3.1. # Getting started ## As a Command Line Tool ### Build ``` $ make ``` Once you've compiled successfully you will get a script called `emqtt` in `_buile/emqtt/rel/emqtt/bin`. We can see what `emqtt` can do with `--help` option: ``` $ ./emqtt --help Usage: emqtt pub | sub [--help] ``` `emqtt pub` is used to publish a single message on a topic and exit. `emqtt sub` is used to subscribe to a topic and print the messages that it receives. ### Command-line Syntax Options can have both short (single character) and long (string) option names. A short option can have the following syntax: ``` -e arg Single option 'e', argument "arg" ``` A long option can have the following syntax: ``` --example=arg Single option 'example', argument "arg" --example arg Single option 'example', argument "arg" ``` ### Publish #### Synopsis ``` ./emqtt pub [-h [<host>]] [-p <port>] [-I <iface>] [-V [<protocol_version>]] [-u <username>] [-P <password>] [-C <clientid>] [-k [<keepalive>]] [-t <topic>] [-q [<qos>]] [-r [<retain>]] [--help <help>] [--will-topic <will_topic>] [--will-payload <will_payload>] [--will-qos [<will_qos>]] [--will-retain [<will_retain>]] [--enable-websocket [<enable_websocket>]] [--enable-ssl [<enable_ssl>]] [--tls-version [<tls_version>]] [--CAfile <cafile>] [--cert <cert>] [--key <key>] [--payload <payload>] [--repeat [<repeat>]] [--repeat-delay [<repeat_delay>]] ``` #### Options <span id="host">**`-h, --host`**</span> &ensp;&ensp;Specify the host to connect to, support for domain name and IP address. Defaults to localhost. <span id="port">**`-p, --port`**</span> &ensp;&ensp;Specify the port to connect to. If not given, the default of 1883 for MQTT or 8883 for MQTT over TLS will be used. <span id="iface">**`-I, --iface`**</span> &ensp;&ensp;Specify the network interface or ip address to use. <span id="protocol-version">**`-V, --protocol-version`**</span> &ensp;&ensp;Specify the MQTT protocol version used by the client. Can be `v3.1`, `v3.1.1` and `v5`. Defaults to `v5`. <span id="username">**`-u, --username`**</span> &ensp;&ensp;Specify the username that can be used by the broker for authentication and authorization. <span id="password">**`-P, --password`**</span> &ensp;&ensp;Specify the password for the username. <span id="clientid">**`-C, --clientid`**</span> &ensp;&ensp;Specify the client identifier. If not given, the client identifier in the format `emqtt-<Hostname>-<Random Hexadecimal String>` will be automatically generated by `emqtt_cli`. <span id="keepalive">**`-k, --keepalive`**</span> &ensp;&ensp;Specify the interval in seconds sending PINGREQ packets to the broker. Defaults to 300 seconds. **`-t, --topic`** &ensp;&ensp;Specify the MQTT topic you want to publish. If the topic beginning with $, you must use single quote(`'`) to specify the topic rather than double quotes(`"`). This is a required option. **`-q, --qos`** &ensp;&ensp;Specify the quality of service for the message. Can be 0, 1 and 2. Defaults to 0. **`-r, --retain`** &ensp;&ensp;Specify whether the message is a retained message. Defaults to false. **`--payload`** &ensp;&ensp;Specify the application message is to be published. This is a required option. **`--repeat`** &ensp;&ensp;Specify the number of times the message will be repeatedly published. Defaults to 1. **`--repeat-count`** &ensp;&ensp;Specify the number of seconds to wait after the previous message was delivered before publishing the next. Defaults to 0, it means to publish repeated messages as soon as the previous message is sent. <span id="will-topic">**`--will-topic`**</span> &ensp;&ensp;Specify the topic of the will message sent when the client disconnects unexpectedly. <span id="will-qos">**`--will-qos`**</span> &ensp;&ensp;Specify the quality of service of the will message. Defaults to 0. This must be used in conjunction with `--will-topic`. <span id="will-retain">**`--will-retain`**</span> &ensp;&ensp;Specify whether the will message is a retained message. Defaults to false. This must be used in conjunction with `--will-topic`. <span id="will-payload">**`--will-payload`**</span> &ensp;&ensp;Specify the application message that will be stored by the broker and sent out if this client disconnects unexpectedly. This must be used in conjunction with `--will-topic`. <span id="enable-websocket">**`--enable-websocket`**</span> &ensp;&ensp;Specify enable WebSocket transport or not. This option can't be used with `--enable-ssl` currently. <span id="enable-ssl">**`--enable-ssl`**</span> &ensp;&ensp;Specify enable SSL/TLS transport or not. This option can't be used with `--enable-websocket` currently. <span id="tls-version">**`--tls-version`**</span> &ensp;&ensp;Specify which TLS protocol version to use when communicating with the broker. Valid options are tlsv1.3, tlsv1.2, tlsv1.1 and tlsv1. Defaults to tlsv1.2. <span id="CAfile">**`--CAfile`**</span> &ensp;&ensp;Specify the path to a file containing PEM encoded CA certificates. This must be used in conjunction with `--enable-ssl`. <span id="cert">**`--cert`**</span> &ensp;&ensp;Specify the path to a file containing a PEM encoded certificate for this client, if required by the server. This must be used in conjunction with `--enable-ssl`. <span id="key">**`--key`**</span> &ensp;&ensp;Specify the path to a file containing a PEM encoded private key for this client, if required by the server. This must be used in conjunction with `--enable-ssl`. #### Examples **Publish a simple message over a TCP connection** ``` $ ./emqtt pub -t "hello" --payload "hello world" Client emqtt-zhouzibodeMacBook-Pro-4623faa14d8256e9cb95 sent CONNECT Client emqtt-zhouzibodeMacBook-Pro-4623faa14d8256e9cb95 sent PUBLISH (Q0, R0, D0, Topic=hello, Payload=...(11 bytes)) Client emqtt-zhouzibodeMacBook-Pro-4623faa14d8256e9cb95 sent DISCONNECT ``` **Publish a simple message over a TLS connection** ``` $ ./emqtt pub --enable-ssl=true -t "hello" --payload "hello world" --CAfile=certs/cacert.pem --cert=certs/client-cert.pem --key=certs/client-key.pem Client emqtt-zhouzibodeMacBook-Pro-cec9489c26e3ed7a38eb sent CONNECT Client emqtt-zhouzibodeMacBook-Pro-cec9489c26e3ed7a38eb sent PUBLISH (Q0, R0, D0, Topic=hello, Payload=...(11 bytes)) Client emqtt-zhouzibodeMacBook-Pro-cec9489c26e3ed7a38eb sent DISCONNECT ``` **Publish a message repeatedly over a WebSocket connection** ``` $ ./emqtt pub --enable-websocket=true -p 8083 -t "hello" --payload "hello world" Client emqtt-zhouzibodeMacBook-Pro-1e4677ab46cecf1298ac sent CONNECT Client emqtt-zhouzibodeMacBook-Pro-1e4677ab46cecf1298ac sent PUBLISH (Q0, R0, D0, Topic=hello, Payload=...(11 bytes)) Client emqtt-zhouzibodeMacBook-Pro-1e4677ab46cecf1298ac sent DISCONNECT ``` ### Subscribe #### Synopsis ``` ./emqtt sub [-h [<host>]] [-p <port>] [-I <iface>] [-V [<protocol_version>]] [-u <username>] [-P <password>] [-C <clientid>] [-k [<keepalive>]] [-t <topic>] [-q [<qos>]] [--help <help>] [--will-topic <will_topic>] [--will-payload <will_payload>] [--will-qos [<will_qos>]] [--will-retain [<will_retain>]] [--enable-websocket [<enable_websocket>]] [--enable-ssl [<enable_ssl>]] [--tls-version [<tls_version>]] [--CAfile <cafile>] [--cert <cert>] [--key <key>] [--retain-as-publish [<retain_as_publish>]] [--retain-handling [<retain_handling>]] ``` #### Options **`-h, --host`** &ensp;&ensp;See also [--host](#host). **`-p, --port`** &ensp;&ensp;See also [--port](#port). **`-I, --iface`** &ensp;&ensp;See also [--iface](#iface). **`-V, --protocol-version`** &e
评论
    相关推荐
    • erlang 21.3
      erlang21.3版本安装包 ,otp_src_21.3.tar.gz。官网下载实在是太慢了。
    • poolboy erlang
      poolboy erlang 线程池 一个用erlang写的pool库
    • erlang安装包
      http://www.erlang.org/downloads官网下载太慢,现放上来与大家共享
    • Erlang中文手册
      Erlang 中文手册 译者 注...........................................................I 其它译者..........................................................II 第 1 部分 入门....................................
    • Erlang实战
      Erlang实战
    • bazel-erlang
      bazel_erlang 适用于Erlang来源的Bazel规则 最小的例子 load ( "@bazel-erlang//:bazel_erlang_lib.bzl" , "bazel_erlang_lib" , "erlang_lib" , "erlc" ) load ( "@bazel-erlang//:ct.bzl" , "ct_suite" ) APP_...
    • erlang programming
      Programming+Erlang.pdf+ 面对软件错误构建可靠的分布式系统.pdf+ Concurrent Programming in ERLANG
    • erlang资源
      erlang资源,非常值得下载,二郎学习
    • Erlang入门
      一本简约的Erlang语言入门书, 本书涵盖了从Erlang的起源到广泛应用的高可靠消息专递系统。
    • erlang 开发
      [Erlang.and.OTP.实战].(Erlang.and.OTP.in.Action).M.Logan&E.Merritt&R.Carlsson.文字版.pdf Programming Erlang_ Software for a Concurrent World(Erlang程序设计).pdf