emqttd.config.development 7.6 KB

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