emqttd.config.development 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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. ]},
  86. %% Session
  87. {session, [
  88. %% Max number of QoS 1 and 2 messages that can be “in flight” at one time.
  89. %% 0 means no limit
  90. {max_inflight, 100},
  91. %% Retry interval for redelivering QoS1/2 messages.
  92. {unack_retry_interval, 20},
  93. %% Awaiting PUBREL Timeout
  94. {await_rel_timeout, 20},
  95. %% Max Packets that Awaiting PUBREL, 0 means no limit
  96. {max_awaiting_rel, 0},
  97. %% Statistics Collection Interval(seconds)
  98. {collect_interval, 20},
  99. %% Expired after 2 day (unit: minute)
  100. {expired_after, 2880}
  101. ]},
  102. %% Queue
  103. {queue, [
  104. %% simple | priority
  105. {type, simple},
  106. %% Topic Priority: 0~255, Default is 0
  107. %% {priority, [{"topic/1", 10}, {"topic/2", 8}]},
  108. %% Max queue length. Enqueued messages when persistent client disconnected,
  109. %% or inflight window is full.
  110. {max_length, infinity},
  111. %% Low-water mark of queued messages
  112. {low_watermark, 0.2},
  113. %% High-water mark of queued messages
  114. {high_watermark, 0.6},
  115. %% Queue Qos0 messages?
  116. {queue_qos0, true}
  117. ]}
  118. ]},
  119. %% Broker Options
  120. {broker, [
  121. %% System interval of publishing broker $SYS messages
  122. {sys_interval, 60},
  123. %% Retained messages
  124. {retained, [
  125. %% Expired after seconds, never expired if 0
  126. {expired_after, 0},
  127. %% Max number of retained messages
  128. {max_message_num, 100000},
  129. %% Max Payload Size of retained message
  130. {max_playload_size, 65536}
  131. ]},
  132. %% PubSub and Router
  133. {pubsub, [
  134. %% Default should be scheduler numbers
  135. {pool_size, 8},
  136. %% Store Subscription: true | false
  137. {subscription, true},
  138. %% Route aging time(seconds)
  139. {route_aging, 5}
  140. ]},
  141. %% Bridge
  142. {bridge, [
  143. %%TODO: bridge queue size
  144. {max_queue_len, 10000},
  145. %% Ping Interval of bridge node
  146. {ping_down_interval, 1} %seconds
  147. ]}
  148. ]},
  149. %% Modules
  150. {modules, [
  151. %% Client presence management module.
  152. %% Publish messages when client connected or disconnected
  153. {presence, [{qos, 0}]},
  154. %% Subscribe topics automatically when client connected
  155. {subscription, [
  156. %% $c will be replaced by clientid
  157. %% {"$queue/clients/$c", 1},
  158. %% Static subscriptions from backend
  159. backend
  160. ]}
  161. %% Rewrite rules
  162. %% {rewrite, [{file, "etc/rewrite.config"}]}
  163. ]},
  164. %% Plugins
  165. {plugins, [
  166. %% Plugin App Library Dir
  167. {plugins_dir, "./plugins"},
  168. %% File to store loaded plugin names.
  169. {loaded_file, "./data/loaded_plugins"}
  170. ]},
  171. %% Listeners
  172. {listeners, [
  173. {mqtt, 1883, [
  174. %% Size of acceptor pool
  175. {acceptors, 16},
  176. %% Maximum number of concurrent clients
  177. {max_clients, 512},
  178. %% Socket Access Control
  179. {access, [{allow, all}]},
  180. %% Connection Options
  181. {connopts, [
  182. %% Rate Limit. Format is 'burst, rate', Unit is KB/Sec
  183. %% {rate_limit, "100,10"} %% 100K burst, 10K rate
  184. ]},
  185. %% Socket Options
  186. {sockopts, [
  187. %Set buffer if hight thoughtput
  188. %{recbuf, 4096},
  189. %{sndbuf, 4096},
  190. %{buffer, 4096},
  191. %{nodelay, true},
  192. {backlog, 512}
  193. ]}
  194. ]},
  195. {mqtts, 8883, [
  196. %% Size of acceptor pool
  197. {acceptors, 4},
  198. %% Maximum number of concurrent clients
  199. {max_clients, 512},
  200. %% Socket Access Control
  201. {access, [{allow, all}]},
  202. %% SSL certificate and key files
  203. {ssl, [{certfile, "etc/ssl/ssl.crt"},
  204. {keyfile, "etc/ssl/ssl.key"}]},
  205. %% Socket Options
  206. {sockopts, [
  207. {backlog, 1024}
  208. %{buffer, 4096},
  209. ]}
  210. ]},
  211. %% WebSocket over HTTPS Listener
  212. %% {https, 8083, [
  213. %% %% Size of acceptor pool
  214. %% {acceptors, 4},
  215. %% %% Maximum number of concurrent clients
  216. %% {max_clients, 512},
  217. %% %% Socket Access Control
  218. %% {access, [{allow, all}]},
  219. %% %% SSL certificate and key files
  220. %% {ssl, [{certfile, "etc/ssl/ssl.crt"},
  221. %% {keyfile, "etc/ssl/ssl.key"}]},
  222. %% %% Socket Options
  223. %% {sockopts, [
  224. %% %{buffer, 4096},
  225. %% {backlog, 1024}
  226. %% ]}
  227. %%]},
  228. %% HTTP and WebSocket Listener
  229. {http, 8083, [
  230. %% Size of acceptor pool
  231. {acceptors, 4},
  232. %% Maximum number of concurrent clients
  233. {max_clients, 64},
  234. %% Socket Access Control
  235. {access, [{allow, all}]},
  236. %% Socket Options
  237. {sockopts, [
  238. {backlog, 1024}
  239. %{buffer, 4096},
  240. ]}
  241. ]}
  242. ]},
  243. %% Erlang System Monitor
  244. {sysmon, [
  245. %% Long GC
  246. {long_gc, 100},
  247. %% Long Schedule(ms)
  248. {long_schedule, 100},
  249. %% 8M words. 32MB on 32-bit VM, 64MB on 64-bit VM.
  250. %% 8 * 1024 * 1024
  251. {large_heap, 8388608},
  252. %% Busy Port
  253. {busy_port, true},
  254. %% Busy Dist Port
  255. {busy_dist_port, true}
  256. ]}
  257. ]}
  258. ].