{"record":{"id":"9fb6abfa31a0587e","repo":"redis/redis-py","slug":"maintenance-notifications-handlers-on-connection-a","errorCode":null,"errorMessage":"Maintenance notifications handlers on connection are only supported with RESP version 3","messagePattern":"Maintenance notifications handlers on connection are only supported with RESP version 3","errorType":"exception","errorClass":"RedisError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/client.py","lineNumber":469,"sourceCode":"                            \"ssl_keyfile\": ssl_keyfile,\n                            \"ssl_certfile\": ssl_certfile,\n                            \"ssl_cert_reqs\": ssl_cert_reqs,\n                            \"ssl_include_verify_flags\": ssl_include_verify_flags,\n                            \"ssl_exclude_verify_flags\": ssl_exclude_verify_flags,\n                            \"ssl_ca_certs\": ssl_ca_certs,\n                            \"ssl_ca_data\": ssl_ca_data,\n                            \"ssl_ca_path\": ssl_ca_path,\n                            \"ssl_check_hostname\": ssl_check_hostname,\n                            \"ssl_min_version\": ssl_min_version,\n                            \"ssl_ciphers\": ssl_ciphers,\n                            \"ssl_password\": ssl_password,\n                        }\n                    )\n            maint_notifications_enabled = (\n                maint_notifications_config and maint_notifications_config.enabled\n            )\n            if maint_notifications_enabled and not check_protocol_version(protocol, 3):\n                raise RedisError(\n                    \"Maintenance notifications handlers on connection are only supported with RESP version 3\"\n                )\n            if maint_notifications_config:\n                kwargs.update(\n                    {\n                        \"maint_notifications_config\": maint_notifications_config,\n                    }\n                )\n            # This arg only used if no pool is passed in\n            self.auto_close_connection_pool = auto_close_connection_pool\n            connection_pool = ConnectionPool(**kwargs)\n            self._event_dispatcher.dispatch(\n                AfterPooledConnectionsInstantiationEvent(\n                    [connection_pool], ClientType.ASYNC, credential_provider\n                )\n            )\n        else:\n            # If a pool is passed in, do not close it","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/asyncio/client.py#L451-L487","documentation":"Raised when an async Redis client is constructed with a maint_notifications_config whose enabled flag is True while the negotiated wire protocol is not RESP3 (protocol != 3). Maintenance notifications are pushed by the server only via the RESP3 push type, so the library refuses to start a client that could never receive them. The guard lives in Redis.__init__ after the connection kwargs are assembled, before the connection pool is created.","triggerScenarios":"Constructing redis.asyncio.Redis(maint_notifications_config=MaintNotificationsConfig(enabled=True), protocol=2) (or omitting protocol while the connection default is RESP2), or passing a config object built with enabled=True to from_url without forcing protocol=3.","commonSituations":"Copying a maintenance-notification example into an app whose other clients still use protocol=2; upgrading redis-py to enable maintenance notifications on a legacy RESP2 deployment; setting the env var REDIS_PROTOCOL=2 globally and then enabling notifications on one client.","solutions":["Set protocol=3 on the same Redis() call that passes maint_notifications_config.","If you must stay on RESP2, pass maint_notifications_config=None (or enabled=False).","Confirm the server is Redis >= 7.0 (maintenance notifications require RESP3 support)."],"exampleFix":"// before\nclient = redis.asyncio.Redis(\n    maint_notifications_config=MaintNotificationsConfig(enabled=True),\n    protocol=2,\n)\n// after\nclient = redis.asyncio.Redis(\n    maint_notifications_config=MaintNotificationsConfig(enabled=True),\n    protocol=3,\n)","handlingStrategy":"validation","validationCode":"from redis._parsers.helpers import check_protocol_version\nif maint_cfg and maint_cfg.enabled and not check_protocol_version(protocol, 3):\n    raise ValueError('enable RESP3 (protocol=3) before maint notifications')","typeGuard":"def can_use_maint_notifications(protocol: int | None) -> bool:\n    return check_protocol_version(protocol, 3)","tryCatchPattern":"try:\n    client = redis.asyncio.Redis(maint_notifications_config=cfg, protocol=protocol)\nexcept RedisError as e:\n    if 'RESP version 3' in str(e):\n        client = redis.asyncio.Redis(maint_notifications_config=None, protocol=protocol)\n    else:\n        raise","preventionTips":["Keep a single helper that always sets protocol=3 when maint_notifications_config is enabled.","Assert the protocol/notifications pairing in a unit test."],"tags":["resp3","maintenance-notifications","client-init","configuration"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}