{"record":{"id":"cbc008dc3ee920ae","repo":"nats-io/nats-server","slug":"mqttconnackrcunacceptableprotocolversion","errorCode":"mqttConnAckRCUnacceptableProtocolVersion","errorMessage":"unacceptable protocol version of %v","messagePattern":"unacceptable protocol version of (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/mqtt.go","lineNumber":3810,"sourceCode":"\t}\n\n\t// Spec [MQTT-3.1.2-1]\n\tif !bytes.Equal(proto, mqttProtoName) {\n\t\t// Check proto name against v3.1 to report better error\n\t\tif bytes.Equal(proto, mqttOldProtoName) {\n\t\t\treturn 0, nil, fmt.Errorf(\"older protocol %q not supported\", proto)\n\t\t}\n\t\treturn 0, nil, fmt.Errorf(\"expected connect packet with protocol name %q, got %q\", mqttProtoName, proto)\n\t}\n\n\t// Protocol level\n\tlevel, err := r.readByte(\"protocol level\")\n\tif err != nil {\n\t\treturn 0, nil, err\n\t}\n\t// Spec [MQTT-3.1.2-2]\n\tif level != mqttProtoLevel {\n\t\treturn mqttConnAckRCUnacceptableProtocolVersion, nil, fmt.Errorf(\"unacceptable protocol version of %v\", level)\n\t}\n\n\tcp := &mqttConnectProto{}\n\t// Connect flags\n\tcp.flags, err = r.readByte(\"flags\")\n\tif err != nil {\n\t\treturn 0, nil, err\n\t}\n\n\t// Spec [MQTT-3.1.2-3]\n\tif cp.flags&mqttConnFlagReserved != 0 {\n\t\treturn 0, nil, errMQTTConnFlagReserved\n\t}\n\n\tvar hasWill bool\n\twqos := (cp.flags & mqttConnFlagWillQoS) >> 3\n\twretain := cp.flags&mqttConnFlagWillRetain != 0\n\t// Spec [MQTT-3.1.2-11]","sourceCodeStart":3792,"sourceCodeEnd":3828,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/mqtt.go#L3792-L3828","documentation":"MQTT CONNECT parser guard on the protocol level byte (spec MQTT-3.1.2-2): it differs from the supported mqttProtoLevel. The returned return-code (mqttConnAckRCUnacceptableProtocolVersion) is sent back to the client in the CONNACK before the connection is dropped.","triggerScenarios":"Thrown at server/mqtt.go:3810 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the client's MQTT protocol level to a version supported by the server","Upgrade the client library to an MQTT version compatible with the broker"],"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"}