Преглед изворни кода

fix(limiter): add default connection limiter for listeners

firest пре 3 година
родитељ
комит
d13055be43
2 измењених фајлова са 16 додато и 0 уклоњено
  1. 5 0
      apps/emqx/etc/emqx.conf
  2. 11 0
      apps/emqx/src/emqx_limiter/etc/emqx_limiter.conf

+ 5 - 0
apps/emqx/etc/emqx.conf

@@ -1,11 +1,13 @@
 listeners.tcp.default {
   bind = "0.0.0.0:1883"
   max_connections = 1024000
+  limiter.connection = default
 }
 
 listeners.ssl.default {
   bind = "0.0.0.0:8883"
   max_connections = 512000
+  limiter.connection = default
   ssl_options {
     keyfile = "{{ platform_etc_dir }}/certs/key.pem"
     certfile = "{{ platform_etc_dir }}/certs/cert.pem"
@@ -16,12 +18,14 @@ listeners.ssl.default {
 listeners.ws.default {
   bind = "0.0.0.0:8083"
   max_connections = 1024000
+  limiter.connection = default
   websocket.mqtt_path = "/mqtt"
 }
 
 listeners.wss.default {
   bind = "0.0.0.0:8084"
   max_connections = 512000
+  limiter.connection = default
   websocket.mqtt_path = "/mqtt"
   ssl_options {
     keyfile = "{{ platform_etc_dir }}/certs/key.pem"
@@ -34,6 +38,7 @@ listeners.wss.default {
 #  enabled = false
 #  bind = "0.0.0.0:14567"
 #  max_connections = 1024000
+#  limiter.connection = default
 #  keyfile = "{{ platform_etc_dir }}/certs/key.pem"
 #  certfile = "{{ platform_etc_dir }}/certs/cert.pem"
 #}

+ 11 - 0
apps/emqx/src/emqx_limiter/etc/emqx_limiter.conf

@@ -0,0 +1,11 @@
+limiter {
+  connection {
+    rate = "1000/s"
+    bucket {
+      default {
+        rate = "1000/s"
+        capacity = 1000
+      }
+    }
+  }
+}