From 034b1a789f6269387967aafd3519e69c47762dd7 Mon Sep 17 00:00:00 2001 From: Ery Lee Date: Wed, 7 Jan 2015 14:22:26 +0800 Subject: [PATCH] configuration, cluster --- README.md | 55 ++++++++++++++++++++++++++++++++++-- apps/emqtt/include/emqtt.hrl | 7 +++++ doc/protocol.md | 32 +++++++++++++++++++++ 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 doc/protocol.md diff --git a/README.md b/README.md index de4686df3..44bedc77d 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,63 @@ eMQTT requires Erlang R17+. ## Configuration -...... +### etc/app.config -## Admin and Cluster +``` + {emqtt, [ + {auth, {anonymous, []}}, %internal, anonymous + {listen, [ + {mqtt, 1883, [ + {max_conns, 1024}, + {acceptor_pool, 4} + ]}, + {http, 8883, [ + {max_conns, 512}, + {acceptor_pool, 1} + ]} + ]} + ]} + +``` + +### etc/vm.args + +``` + +-sname emqtt + +-setcookie emqtt + +``` + +When nodes clustered, vm.args should be configured as below: + +``` +-name emqtt@host1 +``` ...... +## Cluster + +Suppose we cluster two nodes on 'host1', 'host2', steps: + +on 'host1': + +``` +./bin/emqtt start +``` + +on 'host2': + +``` +./bin/emqtt start + +./bin/emqtt cluster emqtt@host1 +``` + +Run './bin/emqtt cluster' on 'host1' or 'host2' to check cluster nodes. + ## HTTP API eMQTT support http to publish message. diff --git a/apps/emqtt/include/emqtt.hrl b/apps/emqtt/include/emqtt.hrl index dbffbe0e4..375705483 100644 --- a/apps/emqtt/include/emqtt.hrl +++ b/apps/emqtt/include/emqtt.hrl @@ -41,6 +41,13 @@ -type qos() :: ?QOS_2 | ?QOS_1 | ?QOS_0. +%%------------------------------------------------------------------------------ +%% MQTT Client +%%------------------------------------------------------------------------------ +-record(mqtt_client, { + client_id +}). + %%------------------------------------------------------------------------------ %% MQTT Message %%------------------------------------------------------------------------------ diff --git a/doc/protocol.md b/doc/protocol.md new file mode 100644 index 000000000..2043706b9 --- /dev/null +++ b/doc/protocol.md @@ -0,0 +1,32 @@ +# MQTT Protocol Guide + +## Server or Broker + +A program or device that acts as an intermediary between Clients which publish Application Messages and Clients which have made Subscriptions. + +A Server Accepts Network Connections from Clients. +Accepts Application Messages published by Clients. +Processes Subscribe and Unsubscribe requests from Clients. +Forwards Application Messages that match Client Subscriptions. + + +Client ----> Broker(Server) ----> Client + +Publisher ----> Broker -----> Subscriber + +## Subscription and Session + +### Subscription + +A Subscription comprises a Topic Filter and a maximum QoS. A Subscription is associated with a single Session. A Session can contain more than one Subscription. Each Subscription within a session has a different Topic Filter. + +### Session + +A stateful interaction between a Client and a Server. Some Sessions last only as long as the Network + +Connection, others can span multiple consecutive Network Connections between a Client and a Server. + +## Topic Name and Filter + +An expression contained in a Subscription, to indicate an interest in one or more topics. A Topic Filter can include wildcard characters. +