node {
  name = "emqx@127.0.0.1"
  cookie = "emqxsecretcookie"
  data_dir = "data"
}

log {
  file_handlers.default {
    level = warning
    file = "log/emqx.log"
  }
}

cluster {
  name = emqxcl
  discovery_strategy = manual
}

dashboard {
    listeners.http {
        bind = 18083
    }
    default_username = "admin"
    default_password = "public"
}


authentication = [
  {
    backend = "built_in_database"
    mechanism = "password_based"
    password_hash_algorithm {name = "sha256", salt_position = "suffix"}
    user_id_type = "username"
  }
]
authorization {
  cache {enable = true}
  deny_action = "ignore"
  no_match = "allow"
  sources = [
    {
      body {username = "${username}"}
      connect_timeout = "5s"
      enable_pipelining = 100
      headers {"content-type" = "application/json"}
      method = "post"
      pool_size = 8
      request_timeout = "5s"
      ssl {enable = false, verify = "verify_peer"}
      type = "http"
      url = "http://127.0.0.1:8080"
    },
    {
      enable = true
      path = "etc/acl.conf"
      type = "file"
    }
  ]
}
bridges {
  webhook {
    test {
      connect_timeout = "5s"
      enable_pipelining = 100
      headers {"content-type" = "application/json"}
      method = "post"
      pool_size = 4
      pool_type = "random"
      request_timeout = "15s"
      resource_opts {
        async_inflight_window = 100
        auto_restart_interval = "60s"
        health_check_interval = "15s"
        max_queue_bytes = "1GB"
        query_mode = "async"
        request_timeout = "15s"
        worker_pool_size = 4
      }
      ssl {enable = false, verify = "verify_peer"}
      url = "http://127.0.0.1:8080"
    }
  }
}
gateway {
  mqttsn {
    broadcast = true
    "enable_qos3" = true
    enable_stats = true
    gateway_id = 1
    idle_timeout = "30s"
    listeners {
      udp {
        default {
          bind = "1884"
          max_conn_rate = 1000
          max_connections = 1024000
        }
      }
    }
    mountpoint = ""
    predefined = []
  }
}
limiter {
  bytes_in {burst = "0", rate = "10MB"}
  client {
    bytes_in {
      capacity = "infinity"
      divisible = false
      failure_strategy = "force"
      initial = "0"
      low_watermark = "0"
      max_retry_time = "10s"
      rate = "100KB"
    }
    connection {
      capacity = "infinity"
      divisible = false
      failure_strategy = "force"
      initial = "0"
      low_watermark = "0"
      max_retry_time = "10s"
      rate = "infinity"
    }
    internal {
      capacity = "infinity"
      divisible = false
      failure_strategy = "force"
      initial = "0"
      low_watermark = "0"
      max_retry_time = "10s"
      rate = "infinity"
    }
    message_in {
      capacity = "infinity"
      divisible = false
      failure_strategy = "force"
      initial = "0"
      low_watermark = "0"
      max_retry_time = "10s"
      rate = "infinity"
    }
    message_routing {
      capacity = "infinity"
      divisible = false
      failure_strategy = "force"
      initial = "0"
      low_watermark = "0"
      max_retry_time = "10s"
      rate = "infinity"
    }
  }
  connection {burst = "0", rate = "1000"}
  internal {burst = "0", rate = "infinity"}
  message_in {burst = "0", rate = "1000"}
  message_routing {burst = "0", rate = "infinity"}
}
listeners {
  ssl {
    default {
      bind = "0.0.0.0:8883"
      max_connections = 512000
      ssl_options {
        cacertfile = "etc/certs/cacert.pem"
        certfile = "etc/certs/cert.pem"
        keyfile = "etc/certs/key.pem"
      }
    }
  }
  tcp {
    default {
      acceptors = 16
      bind = "0.0.0.0:1883"
      enable_authn = true
      enabled = true
      limiter {
        bytes_in {
          capacity = "infinity"
          initial = "0"
          rate = "infinity"
        }
        client {
          bytes_in {
            capacity = "infinity"
            divisible = false
            failure_strategy = "force"
            initial = "0"
            low_watermark = "0"
            max_retry_time = "10s"
            rate = "infinity"
          }
          connection {
            capacity = "infinity"
            divisible = false
            failure_strategy = "force"
            initial = "0"
            low_watermark = "0"
            max_retry_time = "10s"
            rate = "infinity"
          }
          message_in {
            capacity = "infinity"
            divisible = false
            failure_strategy = "force"
            initial = "0"
            low_watermark = "0"
            max_retry_time = "10s"
            rate = "infinity"
          }
          message_routing {
            capacity = "infinity"
            divisible = false
            failure_strategy = "force"
            initial = "0"
            low_watermark = "0"
            max_retry_time = "10s"
            rate = "infinity"
          }
        }
        connection {
          capacity = 1000
          initial = "0"
          rate = "1000/s"
        }
        message_in {
          capacity = "infinity"
          initial = "0"
          rate = "infinity"
        }
        message_routing {
          capacity = "infinity"
          initial = "0"
          rate = "infinity"
        }
      }
      max_connections = 2000
      proxy_protocol = false
      proxy_protocol_timeout = "3s"
      tcp_options {
        active_n = 100
        backlog = 1024
        buffer = "4KB"
        high_watermark = "1MB"
        nodelay = true
        reuseaddr = true
        send_timeout = "15s"
        send_timeout_close = true
      }
      zone = "default"
    }
  }
  ws {
    default {
      bind = "0.0.0.0:8083"
      max_connections = 1024000
      websocket {mqtt_path = "/mqtt"}
    }
  }
  wss {
    default {
      bind = "0.0.0.0:8084"
      max_connections = 512000
      ssl_options {
        cacertfile = "etc/certs/cacert.pem"
        certfile = "etc/certs/cert.pem"
        keyfile = "etc/certs/key.pem"
      }
      websocket {mqtt_path = "/mqtt"}
    }
  }
}
log {
  console_handler {
    burst_limit {
      enable = true
      max_count = 10000
      window_time = "1s"
    }
    chars_limit = "unlimited"
    drop_mode_qlen = 3000
    enable = true
    flush_qlen = 8000
    formatter = "text"
    level = "info"
    max_depth = 100
    overload_kill {
      enable = true
      mem_size = "30MB"
      qlen = 20000
      restart_after = "5s"
    }
    single_line = true
    supervisor_reports = "error"
    sync_mode_qlen = 100
    time_offset = "system"
  }
  file_handlers {
    default {
      burst_limit {
        enable = true
        max_count = 10000
        window_time = "1s"
      }
      chars_limit = "unlimited"
      drop_mode_qlen = 3000
      enable = false
      file = "log/emqx.log"
      flush_qlen = 8000
      formatter = "text"
      level = "warning"
      max_depth = 100
      max_size = "50MB"
      overload_kill {
        enable = true
        mem_size = "30MB"
        qlen = 20000
        restart_after = "5s"
      }
      rotation {count = 10, enable = true}
      single_line = true
      supervisor_reports = "error"
      sync_mode_qlen = 100
      time_offset = "system"
    }
  }
}
retainer {
  backend {
    index_specs = [
      [1, 2, 3],
      [1, 3],
      [2, 3],
      [3]
    ]
    max_retained_messages = 0
    storage_type = "ram"
    type = "built_in_database"
  }
  enable = true
  flow_control {
    batch_deliver_limiter {
      capacity = "infinity"
      client {
        capacity = "infinity"
        divisible = false
        failure_strategy = "force"
        initial = "0"
        low_watermark = "0"
        max_retry_time = "10s"
        rate = "infinity"
      }
      initial = "0"
      rate = "infinity"
    }
    batch_deliver_number = 0
    batch_read_number = 0
  }
  max_payload_size = "5MB"
  msg_clear_interval = "0s"
  msg_expiry_interval = "0s"
  stop_publish_clear_msg = false
}
rule_engine {
  ignore_sys_message = true
  jq_function_default_timeout = "10s"
  jq_implementation_module = jq_nif
  rules {
    "rule_bw1q" {
      actions = ["webhook:test"]
      description = ""
      metadata {created_at = 1683878250142}
      sql = "SELECT\n  *\nFROM\n  \"t/#\""
    }
  }
}
