emqttd.config.development 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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 days
  100. {expired_after, 48}
  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. %% Subscription: disc | ram | false
  137. {subscription, ram},
  138. %% Route shard
  139. {route_shard, false},
  140. %% Route delay, false | integer
  141. {route_delay, false},
  142. %% Route aging time(seconds)
  143. {route_aging, 5}
  144. ]},
  145. %% Bridge
  146. {bridge, [
  147. %%TODO: bridge queue size
  148. {max_queue_len, 10000},
  149. %% Ping Interval of bridge node
  150. {ping_down_interval, 1} %seconds
  151. ]}
  152. ]},
  153. %% Modules
  154. {modules, [
  155. %% Client presence management module.
  156. %% Publish messages when client connected or disconnected
  157. {presence, [{qos, 0}]},
  158. %% Subscribe topics automatically when client connected
  159. {subscription, [
  160. %% Subscription from stored table
  161. stored,
  162. %% $u will be replaced with username
  163. {"$Q/username/$u", 1},
  164. %% $c will be replaced with clientid
  165. {"$Q/client/$c", 1}
  166. ]}
  167. %% Rewrite rules
  168. %% {rewrite, [{file, "etc/rewrite.config"}]}
  169. ]},
  170. %% Plugins
  171. {plugins, [
  172. %% Plugin App Library Dir
  173. {plugins_dir, "./plugins"},
  174. %% File to store loaded plugin names.
  175. {loaded_file, "./data/loaded_plugins"}
  176. ]},
  177. %% Listeners
  178. {listeners, [
  179. {mqtt, 1883, [
  180. %% Size of acceptor pool
  181. {acceptors, 16},
  182. %% Maximum number of concurrent clients
  183. {max_clients, 512},
  184. %% Socket Access Control
  185. {access, [{allow, all}]},
  186. %% Connection Options
  187. {connopts, [
  188. %% Rate Limit. Format is 'burst, rate', Unit is KB/Sec
  189. %% {rate_limit, "100,10"} %% 100K burst, 10K rate
  190. ]},
  191. %% Socket Options
  192. {sockopts, [
  193. %Set buffer if hight thoughtput
  194. %{recbuf, 4096},
  195. %{sndbuf, 4096},
  196. %{buffer, 4096},
  197. %{nodelay, true},
  198. {backlog, 512}
  199. ]}
  200. ]},
  201. {mqtts, 8883, [
  202. %% Size of acceptor pool
  203. {acceptors, 4},
  204. %% Maximum number of concurrent clients
  205. {max_clients, 512},
  206. %% Socket Access Control
  207. {access, [{allow, all}]},
  208. %% SSL certificate and key files
  209. {ssl, [{certfile, "etc/ssl/ssl.crt"},
  210. {keyfile, "etc/ssl/ssl.key"}]},
  211. %% Socket Options
  212. {sockopts, [
  213. {backlog, 1024}
  214. %{buffer, 4096},
  215. ]}
  216. ]},
  217. %% WebSocket over HTTPS Listener
  218. %% {https, 8083, [
  219. %% %% Size of acceptor pool
  220. %% {acceptors, 4},
  221. %% %% Maximum number of concurrent clients
  222. %% {max_clients, 512},
  223. %% %% Socket Access Control
  224. %% {access, [{allow, all}]},
  225. %% %% SSL certificate and key files
  226. %% {ssl, [{certfile, "etc/ssl/ssl.crt"},
  227. %% {keyfile, "etc/ssl/ssl.key"}]},
  228. %% %% Socket Options
  229. %% {sockopts, [
  230. %% %{buffer, 4096},
  231. %% {backlog, 1024}
  232. %% ]}
  233. %%]},
  234. %% HTTP and WebSocket Listener
  235. {http, 8083, [
  236. %% Size of acceptor pool
  237. {acceptors, 4},
  238. %% Maximum number of concurrent clients
  239. {max_clients, 64},
  240. %% Socket Access Control
  241. {access, [{allow, all}]},
  242. %% Socket Options
  243. {sockopts, [
  244. {backlog, 1024}
  245. %{buffer, 4096},
  246. ]}
  247. ]}
  248. ]},
  249. %% Erlang System Monitor
  250. {sysmon, [
  251. %% Long GC
  252. {long_gc, 100},
  253. %% Long Schedule(ms)
  254. {long_schedule, 100},
  255. %% 8M words. 32MB on 32-bit VM, 64MB on 64-bit VM.
  256. %% 8 * 1024 * 1024
  257. {large_heap, 8388608},
  258. %% Busy Port
  259. {busy_port, true},
  260. %% Busy Dist Port
  261. {busy_dist_port, true}
  262. ]}
  263. ]}
  264. ].