# Path to pid file.
# If not set, there will be no pid file.
# pid_file: /var/run/mqttd.pid

listeners:
  # bind address
  - address: ":58090" # 58090

#  - address: ":21883" # 21883
#    tls:
#      cacert: "/etc/mqtt-broker/ca.crt"
#      cert: "/etc/mqtt-broker/server.pem"
#      key: "/etc/mqtt-broker/server.key"
#
#      cacert: "cmd/mqtt-broker/res/ca.crt"
#      cert: "cmd/mqtt-broker/res/server.pem"
#      key: "cmd/mqtt-broker/res/server.key"
#
#  - address: ":28883" # 28883
#    # websocket setting
#    websocket:
#      path: "/"

api:
  grpc:
    # The gRPC server listen address. Supports unix socket and tcp socket.
    - address: "tcp://127.0.0.1:57090" # 57090
  http:
      # The HTTP server listen address. This is a reverse-proxy server in front of gRPC server.
    - address: "tcp://127.0.0.1:57091" # 57091
      map: "tcp://127.0.0.1:57090" # The backend gRPC server endpoint,

mqtt:
  # The maximum session expiry interval in seconds.
  session_expiry: 2h
  # The interval time for session expiry checker to check whether there are expired sessions.
  session_expiry_check_timer: 20s
  # The maximum lifetime of the message in seconds.
  # If a message in the queue is not sent in message_expiry time, it will be dropped, which means it will not be sent to the subscriber.
  message_expiry: 2h
  # The lifetime of the "inflight" message in seconds.
  #	If a "inflight" message is not acknowledged by a client in inflight_expiry time, it will be removed when the message queue is full.
  inflight_expiry: 30s
  # The maximum packet size that the server is willing to accept from the client.
  max_packet_size: 268435456
  # The maximum number of QoS 1 and QoS 2 publications that the server is willing to process concurrently for the client.
  server_receive_maximum: 100
  # The maximum keep alive time in seconds allows by the server.
  #	If the client requests a keepalive time bigger than MaxKeepalive,the server will use MaxKeepAlive as the keepalive time.
  #	In this case, if the client version is v5, the server will set MaxKeepalive into CONNACK to inform the client.
  #	But if the client version is 3.x, the server has no way to inform the client that the keepalive time has been changed.
  max_keepalive: 300
  # The highest value that the server will accept as a Topic Alias sent by the client.
  # No-op if the client version is MQTTv3.x .
  topic_alias_maximum: 10
  # Whether the server supports Subscription Identifiers.
  # No-op if the client version is MQTTv3.x .
  subscription_identifier_available: true
  # Whether the server supports Wildcard Subscriptions.
  wildcard_subscription_available: true
  # Whether the server supports Shared Subscriptions.
  shared_subscription_available: true
  # The highest QOS level permitted for a Publish.
  maximum_qos: 2
  # Whether the server supports retained messages.
  retain_available: true
  # The maximum queue length of the outgoing messages.
  #	If the queue is full, some message will be dropped.
  #	The message dropping strategy is described in the document of the persistence/queue.Store interface.
  max_queued_messages: 1000
  # The limits of inflight message length of the outgoing messages.
  #	Inflight message is also stored in the message queue, so it must be less than or equal to max_queued_messages.
  #	Inflight message is the QoS 1 or QoS 2 message that has been sent out to a client but not been acknowledged yet.
  max_inflight: 100
  # Whether to store QoS 0 message for a offline session.
  queue_qos0_messages: true
  # The delivery mode. The possible value can be "overlap" or "onlyonce".
  #	It is possible for a client’s subscriptions to overlap so that a published message might match multiple filters.
  #	When set to "overlap" , the server will deliver one message for each matching subscription and respecting the subscription’s QoS in each case.
  #	When set to "onlyonce", the server will deliver the message to the client respecting the maximum QoS of all the matching subscriptions.
  delivery_mode: onlyonce
  # Whether to allow a client to connect with empty client id.
  allow_zero_length_clientid: true

persistence:
  type: memory  # memory | redis
  # The redis configuration only take effect when type == redis.
  redis:
    # redis server address
    addr: "127.0.0.1:56379"
    # the maximum number of idle connections in the redis connection pool.
    max_idle: 1000
    # the maximum number of connections allocated by the redis connection pool at a given time.
    # If zero, there is no limit on the number of connections in the pool.
    max_active: 0
    # the connection idle timeout, connection will be closed after remaining idle for this duration. If the value is zero, then idle connections are not closed.
    idle_timeout: 240s
    password: "qqwihyzjb8l2sx0c"
    # the number of the redis database.
    database: 0

# The topic alias manager setting. The topic alias feature is introduced by MQTT V5.
# This setting is used to control how the broker manage topic alias.
topic_alias_manager:
  # Currently, only FIFO strategy is supported.
  type: fifo

plugins:
  aplugin:
    # Password hash type. (plain | md5 | sha256 | bcrypt)
    # Default to MD5.
    hash: md5
    # The file to store password. If it is a relative path, it locates in the same directory as the config file.
    # (e.g: ./gmqtt_password => /etc/gmqtt/gmqtt_password.yml)
    # Defaults to ./gmqtt_password.yml
    # password_file:
  federation:
    # node_name is the unique identifier for the node in the federation. Defaults to hostname.
    # node_name:
    # fed_addr is the gRPC server listening address for the federation internal communication. Defaults to :8901
    fed_addr: :8901
    # advertise_fed_addr is used to change the federation gRPC server address that we advertise to other nodes in the cluster.
    # Defaults to "fed_addr".However, in some cases, there may be a routable address that cannot be bound.
    # If the port is missing, the default federation port (8901) will be used.
    advertise_fed_addr: :8901
    # gossip_addr is the address that the gossip will listen on, It is used for both UDP and TCP gossip. Defaults to :8902
    gossip_addr: :8902
    # advertise_gossip_addr is used to change the gossip server address that we advertise to other nodes in the cluster.
    # Defaults to "GossipAddr" or the private IP address of the node if the IP in "GossipAddr" is 0.0.0.0.
    # If the port is missing, the default gossip port (8902) will be used.
    advertise_gossip_addr: :8902

    # retry_join is the address of other nodes to join upon starting up.
    # If port is missing, the default gossip port (8902) will be used.
    #retry_join:
    #  - 127.0.0.1:8902

    # rejoin_after_leave will be pass to "RejoinAfterLeave" in serf configuration.
    # It controls our interaction with the snapshot file.
    # When set to false (default), a leave causes a Serf to not rejoin the cluster until an explicit join is received.
    # If this is set to true, we ignore the leave, and rejoin the cluster on start.
    rejoin_after_leave: false
    # snapshot_path will be pass to "SnapshotPath" in serf configuration.
    # When Serf is started with a snapshot,it will attempt to join all the previously known nodes until one
    # succeeds and will also avoid replaying old user events.
    snapshot_path:

# plugin loading orders
plugin_order:
  # Uncomment auth to enable authentication.
  - aplugin
  #- admin
  #- federation
log:
  level: debug # debug | info | warn | error
  file_path: "/logs/mqtt-broker/mqtt-broker.log"
  # whether to dump MQTT packet in debug level
  dump_packet: false

