nats-io/nats-server · error
QoS=2 is disabled for PUBLISH messages
Error message
QoS=2 is disabled for PUBLISH messages
What it means
Server policy check in mqttParsePub: the server option rejectQoS2Pub is enabled and the incoming PUBLISH requests QoS 2, which the operator has explicitly disabled on this broker.
Source
Thrown at server/mqtt.go:4252
c.mu.Unlock()
s.mqttInitiateMsgDelivery(c, pp)
c.flushClients(0)
}
//////////////////////////////////////////////////////////////////////////////
//
// PUBLISH protocol related functions
//
//////////////////////////////////////////////////////////////////////////////
func (c *client) mqttParsePub(r *mqttReader, pl int, pp *mqttPublish, hasMappings bool) error {
qos := mqttGetQoS(pp.flags)
if qos > 2 {
return fmt.Errorf("QoS=%v is invalid in MQTT", qos)
}
if c.mqtt.rejectQoS2Pub && qos == 2 {
return fmt.Errorf("QoS=2 is disabled for PUBLISH messages")
}
// Keep track of where we are when starting to read the variable header
start := r.pos
var err error
pp.topic, err = r.readBytes("topic", false)
if err != nil {
return err
}
if len(pp.topic) == 0 {
return errMQTTTopicIsEmpty
}
if err := mqttValidateTopic(pp.topic, "topic"); err != nil {
return err
}
// Convert the topic to a NATS subject. This call will also check that
// there is no MQTT wildcards (Spec [MQTT-3.3.2-2] and [MQTT-4.7.1-1])View on GitHub (pinned to 3a66a489d2)
Solutions
- Publish with QoS 0 or 1 instead
- Remove/relax the QoS 2 rejection setting on the server if QoS 2 publishing is required
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/mqtt.go:4252 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/737d7322beef7bc5.
Report an issue: GitHub.