emqttd.config.development 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. % -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
  2. %% ex: ft=erlang ts=4 sw=4 et
  3. [{kernel, [
  4. {start_timer, true},
  5. {start_pg2, true}
  6. ]},
  7. {sasl, [
  8. {sasl_error_logger, {file, "log/emqttd_sasl.log"}}
  9. ]},
  10. {ssl, [
  11. %{versions, ['tlsv1.2', 'tlsv1.1']}
  12. ]},
  13. {lager, [
  14. {colored, true},
  15. {async_threshold, 1000},
  16. {error_logger_redirect, false},
  17. {crash_log, "log/emqttd_crash.log"},
  18. {handlers, [
  19. {lager_console_backend, info},
  20. %%NOTICE: Level >= error
  21. %%{lager_emqtt_backend, error},
  22. {lager_file_backend, [
  23. {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]},
  24. {file, "log/emqttd_info.log"},
  25. {level, info},
  26. {size, 104857600},
  27. {date, "$D0"},
  28. {count, 30}
  29. ]},
  30. {lager_file_backend, [
  31. {formatter_config, [time, " ", pid, " [",severity,"] ", message, "\n"]},
  32. {file, "log/emqttd_error.log"},
  33. {level, error},
  34. {size, 104857600},
  35. {date, "$D0"},
  36. {count, 30}
  37. ]}
  38. ]}
  39. ]},
  40. {esockd, [
  41. {logger, {lager, info}}
  42. ]},
  43. {emqttd, [
  44. %% Authentication and Authorization
  45. {access, [
  46. %% Authetication. Anonymous Default
  47. {auth, [
  48. %% Authentication with username, password
  49. %{username, []},
  50. %% Authentication with clientid
  51. %{clientid, [{password, no}, {file, "etc/clients.config"}]},
  52. %% Authentication with LDAP
  53. % {ldap, [
  54. % {servers, ["localhost"]},
  55. % {port, 389},
  56. % {timeout, 30},
  57. % {user_dn, "uid=$u,ou=People,dc=example,dc=com"},
  58. % {ssl, fasle},
  59. % {sslopts, [
  60. % {"certfile", "ssl.crt"},
  61. % {"keyfile", "ssl.key"}]}
  62. % ]},
  63. %% Allow all
  64. {anonymous, []}
  65. ]},
  66. %% ACL config
  67. {acl, [
  68. %% Internal ACL module
  69. {internal, [{file, "etc/acl.config"}, {nomatch, allow}]}
  70. ]}
  71. ]},
  72. %% MQTT Protocol Options
  73. {mqtt, [
  74. %% Packet
  75. {packet, [
  76. %% Max ClientId Length Allowed
  77. {max_clientid_len, 1024},
  78. %% Max Packet Size Allowed, 64K default
  79. {max_packet_size, 65536}
  80. ]},
  81. %% Client
  82. {client, [
  83. %% Socket is connected, but no 'CONNECT' packet received
  84. {idle_timeout, 10} %% seconds
  85. %TODO: Network ingoing limit
  86. %{ingoing_rate_limit, '64KB/s'}
  87. %TODO: Reconnet control
  88. ]},
  89. %% Session
  90. {session, [
  91. %% Max number of QoS 1 and 2 messages that can be “in flight” at one time.
  92. %% 0 means no limit
  93. {max_inflight, 100},
  94. %% Retry interval for redelivering QoS1/2 messages.
  95. {unack_retry_interval, 20},
  96. %% Awaiting PUBREL Timeout
  97. {await_rel_timeout, 20},
  98. %% Max Packets that Awaiting PUBREL, 0 means no limit
  99. {max_awaiting_rel, 0},
  100. %% Statistics Collection Interval(seconds)
  101. {collect_interval, 20},
  102. %% Expired after 2 days
  103. {expired_after, 48}
  104. ]},
  105. %% Session
  106. {queue, [
  107. %% Max queue length. enqueued messages when persistent client disconnected,
  108. %% or inflight window is full.
  109. {max_length, 100},
  110. %% Low-water mark of queued messages
  111. {low_watermark, 0.2},
  112. %% High-water mark of queued messages
  113. {high_watermark, 0.6},
  114. %% Queue Qos0 messages?
  115. {queue_qos0, true}
  116. ]}
  117. ]},
  118. %% Broker Options
  119. {broker, [
  120. %% System interval of publishing broker $SYS messages
  121. {sys_interval, 60},
  122. %% Retained messages
  123. {retained, [
  124. %% Expired after seconds, never expired if 0
  125. {expired_after, 0},
  126. %% Max number of retained messages
  127. {max_message_num, 100000},
  128. %% Max Payload Size of retained message
  129. {max_playload_size, 65536}
  130. ]},
  131. %% PubSub and Router
  132. {pubsub, [
  133. %% Default should be scheduler numbers
  134. {pool_size, 8},
  135. %% Subscription: disc | ram | false
  136. {subscription, ram},
  137. %% Route shard
  138. {route_shard, false},
  139. %% Route delay, false | integer
  140. {route_delay, false},
  141. %% Route aging time(seconds)
  142. {route_aging, 5}
  143. ]},
  144. %% Bridge
  145. {bridge, [
  146. %%TODO: bridge queue size
  147. {max_queue_len, 10000},
  148. %% Ping Interval of bridge node
  149. {ping_down_interval, 1} %seconds
  150. ]}
  151. ]},
  152. %% Modules
  153. {modules, [
  154. %% Client presence management module.
  155. %% Publish messages when client connected or disconnected
  156. {presence, [{qos, 0}]},
  157. %% Subscribe topics automatically when client connected
  158. {subscription, [
  159. %% Subscription from stored table
  160. stored,
  161. %% $u will be replaced with username
  162. {"$Q/username/$u", 1},
  163. %% $c will be replaced with clientid
  164. {"$Q/client/$c", 1}
  165. ]}
  166. %% Rewrite rules
  167. %% {rewrite, [{file, "etc/rewrite.config"}]}
  168. ]},
  169. %% Plugins
  170. {plugins, [
  171. %% Plugin App Library Dir
  172. {plugins_dir, "./plugins"},
  173. %% File to store loaded plugin names.
  174. {loaded_file, "./data/loaded_plugins"}
  175. ]},
  176. %% Listeners
  177. {listeners, [
  178. {mqtt, 1883, [
  179. %% Size of acceptor pool
  180. {acceptors, 16},
  181. %% Maximum number of concurrent clients
  182. {max_clients, 512},
  183. %% Socket Access Control
  184. {access, [{allow, all}]},
  185. %% Connection Options
  186. {connopts, [
  187. %% Rate Limit. Format is 'burst, rate', Unit is KB/Sec
  188. %% {rate_limit, "100,10"} %% 100K burst, 10K rate
  189. ]},
  190. %% Socket Options
  191. {sockopts, [
  192. %Set buffer if hight thoughtput
  193. %{recbuf, 4096},
  194. %{sndbuf, 4096},
  195. %{buffer, 4096},
  196. %{nodelay, true},
  197. {backlog, 512}
  198. ]}
  199. ]},
  200. {mqtts, 8883, [
  201. %% Size of acceptor pool
  202. {acceptors, 4},
  203. %% Maximum number of concurrent clients
  204. {max_clients, 512},
  205. %% Socket Access Control
  206. {access, [{allow, all}]},
  207. %% SSL certificate and key files
  208. {ssl, [{certfile, "etc/ssl/ssl.crt"},
  209. {keyfile, "etc/ssl/ssl.key"}]},
  210. %% Socket Options
  211. {sockopts, [
  212. {backlog, 1024}
  213. %{buffer, 4096},
  214. ]}
  215. ]},
  216. %% WebSocket over HTTPS Listener
  217. %% {https, 8083, [
  218. %% %% Size of acceptor pool
  219. %% {acceptors, 4},
  220. %% %% Maximum number of concurrent clients
  221. %% {max_clients, 512},
  222. %% %% Socket Access Control
  223. %% {access, [{allow, all}]},
  224. %% %% SSL certificate and key files
  225. %% {ssl, [{certfile, "etc/ssl/ssl.crt"},
  226. %% {keyfile, "etc/ssl/ssl.key"}]},
  227. %% %% Socket Options
  228. %% {sockopts, [
  229. %% %{buffer, 4096},
  230. %% {backlog, 1024}
  231. %% ]}
  232. %%]},
  233. %% HTTP and WebSocket Listener
  234. {http, 8083, [
  235. %% Size of acceptor pool
  236. {acceptors, 4},
  237. %% Maximum number of concurrent clients
  238. {max_clients, 64},
  239. %% Socket Access Control
  240. {access, [{allow, all}]},
  241. %% Socket Options
  242. {sockopts, [
  243. {backlog, 1024}
  244. %{buffer, 4096},
  245. ]}
  246. ]}
  247. ]},
  248. %% Erlang System Monitor
  249. {sysmon, [
  250. %% Long GC
  251. {long_gc, 100},
  252. %% Long Schedule(ms)
  253. {long_schedule, 100},
  254. %% 8M words. 32MB on 32-bit VM, 64MB on 64-bit VM.
  255. %% 8 * 1024 * 1024
  256. {large_heap, 8388608},
  257. %% Busy Port
  258. {busy_port, true},
  259. %% Busy Dist Port
  260. {busy_dist_port, true}
  261. ]}
  262. ]}
  263. ].