{"record":{"id":"737d7322beef7bc5","repo":"nats-io/nats-server","slug":"qos-2-is-disabled-for-publish-messages","errorCode":null,"errorMessage":"QoS=2 is disabled for PUBLISH messages","messagePattern":"QoS=2 is disabled for PUBLISH messages","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mqtt.go","lineNumber":4252,"sourceCode":"\tc.mu.Unlock()\n\ts.mqttInitiateMsgDelivery(c, pp)\n\tc.flushClients(0)\n}\n\n//////////////////////////////////////////////////////////////////////////////\n//\n// PUBLISH protocol related functions\n//\n//////////////////////////////////////////////////////////////////////////////\n\nfunc (c *client) mqttParsePub(r *mqttReader, pl int, pp *mqttPublish, hasMappings bool) error {\n\tqos := mqttGetQoS(pp.flags)\n\tif qos > 2 {\n\t\treturn fmt.Errorf(\"QoS=%v is invalid in MQTT\", qos)\n\t}\n\n\tif c.mqtt.rejectQoS2Pub && qos == 2 {\n\t\treturn fmt.Errorf(\"QoS=2 is disabled for PUBLISH messages\")\n\t}\n\n\t// Keep track of where we are when starting to read the variable header\n\tstart := r.pos\n\n\tvar err error\n\tpp.topic, err = r.readBytes(\"topic\", false)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(pp.topic) == 0 {\n\t\treturn errMQTTTopicIsEmpty\n\t}\n\tif err := mqttValidateTopic(pp.topic, \"topic\"); err != nil {\n\t\treturn err\n\t}\n\t// Convert the topic to a NATS subject. This call will also check that\n\t// there is no MQTT wildcards (Spec [MQTT-3.3.2-2] and [MQTT-4.7.1-1])","sourceCodeStart":4234,"sourceCodeEnd":4270,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/mqtt.go#L4234-L4270","documentation":"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.","triggerScenarios":"Thrown at server/mqtt.go:4252 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Publish with QoS 0 or 1 instead","Remove/relax the QoS 2 rejection setting on the server if QoS 2 publishing is required"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}