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 = [
  {
    algorithm = "hmac-based"
    from = "password"
    mechanism = "jwt"
    secret = "emqxsecret"
    "secret_base64_encoded" = false
    use_jwks = false
    verify_claims {}
  }
]
authorization {
  cache {enable = true}
  deny_action = "ignore"
  no_match = "allow"
  sources = [
    {type = "built_in_database"},
    {
      enable = true
      path = "etc/acl.conf"
      type = "file"
    }
  ]
}
bridges {
  mqtt {
    "to-public-broker" {
      bridge_mode = false
      clean_start = true
      egress {
        local {topic = "t/#"}
        remote {
          payload = "${payload}"
          qos = 1
          retain = false
          topic = "b/t"
        }
      }
      enable = true
      keepalive = "300s"
      mode = "cluster_shareload"
      proto_ver = "v4"
      resource_opts {
        auto_restart_interval = "60s"
        health_check_interval = "15s"
        inflight_window = 100
        max_buffer_bytes = "1GB"
        query_mode = "async"
        request_timeout = "15s"
        worker_pool_size = 4
      }
      retry_interval = "15s"
      server = "broker.emqx.io:1883"
      ssl {enable = false, verify = "verify_peer"}
    }
  }
}
exhook {
  servers = [
    {
      auto_reconnect = "60s"
      enable = false
      failed_action = "deny"
      name = "test"
      pool_size = 16
      request_timeout = "5s"
      ssl {enable = false, verify = "verify_peer"}
      url = "http://127.0.0.1:8080/exhook"
    }
  ]
}
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 = []
  }
}
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 = 32
      bind = "0.0.0.0:1883"
      enable_authn = true
      enabled = true
      limiter {
        bytes {rate = "infinity"}
        client {
          bytes {rate = "infinity"}
          messages {rate = "infinity"}
        }
        messages {rate = "infinity"}
      }
      max_connections = 1024000
      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"}
    }
  }
}
mqtt {
  await_rel_timeout = "300s"
  exclusive_subscription = true
  idle_timeout = "15s"
  ignore_loop_deliver = true
  keepalive_backoff = 1
  max_awaiting_rel = 100
  max_clientid_len = 65535
  max_inflight = 32
  max_mqueue_len = 1000
  max_packet_size = "1MB"
  max_qos_allowed = 2
  max_subscriptions = 100
  max_topic_alias = 65535
  max_topic_levels = 128
  mqueue_default_priority = "lowest"
  mqueue_priorities = "disabled"
  "mqueue_store_qos0" = true
  peer_cert_as_clientid = "cn"
  peer_cert_as_username = "cn"
  response_information = ""
  retain_available = true
  retry_interval = "30s"
  server_keepalive = 200
  session_expiry_interval = "2h"
  shared_subscription = true
  strict_mode = true
  upgrade_qos = true
  use_username_as_clientid = true
  wildcard_subscription = true
}
retainer {
  backend {
    index_specs = [
      [1, 2, 3],
      [1, 3],
      [2, 3],
      [3]
    ]
    max_retained_messages = 1000
    storage_type = "ram"
    type = "built_in_database"
  }
  enable = true
  max_payload_size = "1MB"
  msg_clear_interval = "20000ms"
  msg_expiry_interval = "10000ms"
  stop_publish_clear_msg = false
}
rule_engine {
  ignore_sys_message = true
  jq_function_default_timeout = "10s"
  rules {
    rule_tcbl {
      actions = ["mqtt:to-public-broker"]
      description = ""
      metadata {created_at = 1684223521242}
      sql = "SELECT\n  *\nFROM\n  \"t/#\""
    }
  }
}
sys_topics {
  sys_event_messages {
    client_connected = true
    client_disconnected = true
    client_subscribed = true
    client_unsubscribed = true
  }
  sys_heartbeat_interval = "30s"
  sys_msg_interval = "1m"
}
sysmon {
  os {
    cpu_check_interval = "60s"
    cpu_high_watermark = "80%"
    cpu_low_watermark = "60%"
    mem_check_interval = "60s"
    procmem_high_watermark = "5%"
    sysmem_high_watermark = "70%"
  }
  top {
    db_hostname = ""
    db_name = "postgres"
    db_password = "******"
    db_port = 5432
    db_username = "system_monitor"
    max_procs = 1000000
    num_items = 10
    sample_interval = "2s"
  }
  vm {
    busy_dist_port = true
    busy_port = true
    large_heap = "32MB"
    long_gc = "100ms"
    long_schedule = "240ms"
    process_check_interval = "30s"
    process_high_watermark = "80%"
    process_low_watermark = "60%"
  }
}
