Versions in this module Expand all Collapse all v0 v0.6.0 Oct 26, 2026 v0.5.0 Oct 26, 2026 Changes in this version type Client + func (c *Client) Ack(m *Message) error type Options + ManualAck bool v0.4.0 Oct 26, 2026 Changes in this version type Message + Dup bool v0.3.0 Oct 21, 2026 Changes in this version type Server + Dial func(ctx context.Context, network, address string) (net.Conn, error) v0.2.0 Oct 19, 2026 v0.1.0 Oct 12, 2026 Changes in this version + const DefaultMaxInflight + const DefaultReceiveMaximum + const MQTT31 + const MQTT311 + const MQTT5 + var ErrAlreadyConnected = errors.New("mqttclient: already connected or connecting") + var ErrConnectionLost = errors.New("mqttclient: connection lost") + var ErrDisconnected = errors.New("mqttclient: disconnected by the application") + var ErrInvalid = errors.New("mqttclient: invalid argument") + var ErrKeepalive = errors.New("mqttclient: keepalive timeout") + var ErrMalformedPacket = errors.New("mqttclient: malformed packet") + var ErrNoConn = errors.New("mqttclient: not connected") + var ErrNoMid = errors.New("mqttclient: all message ids are in use") + var ErrNotSupported = errors.New("mqttclient: not supported") + var ErrOversizePacket = errors.New("mqttclient: packet exceeds maximum packet size") + var ErrProtocol = errors.New("mqttclient: protocol error") + var ErrQoSNotSupported = errors.New("mqttclient: qos not supported by the server") + var ErrRunning = errors.New("mqttclient: Run is managing the connection") + var ErrServerDisconnect = errors.New("mqttclient: server sent DISCONNECT") + func ReasonCodeString(code byte) string + type Client struct + func New(opts Options, h Handlers) (*Client, error) + func (c *Client) ClientID() string + func (c *Client) Connect(ctx context.Context) (ConnAck, error) + func (c *Client) Disconnect(ctx context.Context, reason byte, props *Properties) error + func (c *Client) IsConnected() bool + func (c *Client) Publish(ctx context.Context, m *Message) (*Pending, error) + func (c *Client) Run(ctx context.Context) error + func (c *Client) ServerIndex() int + func (c *Client) SetCredentials(username string, password []byte) error + func (c *Client) SetWill(w *Message) error + func (c *Client) Subscribe(ctx context.Context, subs []Subscription, props *Properties) (*Pending, error) + func (c *Client) Unsubscribe(ctx context.Context, topics []string, props *Properties) (*Pending, error) + type ConnAck struct + Properties *Properties + ReasonCode byte + SessionPresent bool + type ConnRefusedError struct + ProtocolVersion byte + ReasonCode byte + func (e *ConnRefusedError) Error() string + type DisconnectEvent struct + Err error + Properties *Properties + ReasonCode byte + type Handlers struct + OnConnect func(c *Client, ack ConnAck) + OnConnectError func(c *Client, err error) + OnDisconnect func(c *Client, ev DisconnectEvent) + OnMessage func(c *Client, m *Message) + OnPreConnect func(c *Client) + OnPublish func(c *Client, mid uint16, reason byte, props *Properties) + OnSubscribe func(c *Client, mid uint16, granted []byte, props *Properties) + OnUnsubscribe func(c *Client, mid uint16, reasons []byte, props *Properties) + type Message struct + Mid uint16 + Payload []byte + Properties *Properties + QoS byte + Retain bool + Topic string + type Options struct + Logger *slog.Logger + NoTopicCheck bool + Servers []Server + type Pending struct + Mid uint16 + func (p *Pending) Done() <-chan struct{} + func (p *Pending) Wait(ctx context.Context) (Result, error) + type Properties = packets.Properties + type ReasonCodeError struct + Packet string + ReasonCode byte + func (e *ReasonCodeError) Error() string + type Result struct + Properties *Properties + ReasonCode byte + ReasonCodes []byte + type Server struct + Address string + CleanStart bool + ClientID string + ConnectProperties *Properties + ConnectTimeout time.Duration + KeepAlive uint16 + MaxInflight uint16 + Password []byte + ProtocolVersion byte + ReceiveMaximum uint16 + ReconnectDelay time.Duration + ReconnectDelayMax time.Duration + ReconnectExponential bool + TLS bool + TLSConfig *tls.Config + Username string + Will *Message + type Subscription struct + NoLocal bool + QoS byte + RetainAsPublished bool + RetainHandling byte + Topic string + type UserProperty = packets.UserProperty