redis/redis-py · error · NotImplementedError
Maintenance notifications are not supported by this connecti
Error message
Maintenance notifications are not supported by this connection type
What it means
Raised as a NotImplementedError in CacheProxyConnection._get_socket when the wrapped _conn is not an instance of MaintNotificationsAbstractConnection. The proxy delegates socket access only to connections that support maintenance notifications; a plain Connection lacks the maintenance plumbing and cannot expose its socket through this API.
Source
Thrown at redis/connection.py:1968
@property
def _maint_notifications_connection_handler(
self,
) -> Optional[MaintNotificationsConnectionHandler]:
if isinstance(self._conn, MaintNotificationsAbstractConnection):
return self._conn._maint_notifications_connection_handler
@_maint_notifications_connection_handler.setter
def _maint_notifications_connection_handler(
self, value: Optional[MaintNotificationsConnectionHandler]
):
self._conn._maint_notifications_connection_handler = value
def _get_socket(self) -> Optional[socket.socket]:
if isinstance(self._conn, MaintNotificationsAbstractConnection):
return self._conn._get_socket()
else:
raise NotImplementedError(
"Maintenance notifications are not supported by this connection type"
)
def _get_maint_notifications_connection_instance(
self, connection
) -> MaintNotificationsAbstractConnection:
"""
Validate that connection instance supports maintenance notifications.
With this helper method we ensure that we are working
with the correct connection type.
After twe validate that connection instance supports maintenance notifications
we can safely return the connection instance
as MaintNotificationsAbstractConnection.
"""
if not isinstance(connection, MaintNotificationsAbstractConnection):
raise NotImplementedError(
"Maintenance notifications are not supported by this connection type"
)View on GitHub (pinned to da03cdc7e8)
Solutions
- Use a connection type that extends MaintNotificationsAbstractConnection when you need both CSC and maintenance APIs.
- Avoid calling maintenance-notification accessors on connections that do not support them.
- Check isinstance before calling, or disable maintenance-notification features for this connection.
Example fix
// before sock = proxy_conn._get_socket() # _conn is a plain Connection // after # use a maint-enabled connection type, or do not call _get_socket
Defensive patterns
Strategy: type-guard
Validate before calling
from redis.maint_notifications import MaintNotificationsAbstractConnection
if not isinstance(proxy_conn._conn, MaintNotificationsAbstractConnection):
raise NotImplementedError('Underlying connection does not support maintenance notifications') Type guard
from redis.maint_notifications import MaintNotificationsAbstractConnection
def is_maint_capable(conn) -> bool:
return isinstance(getattr(conn, '_conn', conn), MaintNotificationsAbstractConnection) Try / catch
try:
sock = proxy_conn._get_socket()
except NotImplementedError:
# connection type lacks maintenance support; skip maintenance APIs
pass Prevention
- Only call maintenance-notification socket accessors on MaintNotificationsAbstractConnection instances.
- Guard with isinstance before invoking maintenance APIs on proxied connections.
When it happens
Trigger: Calling getpeername/get_resolved_ip/maintenance-state accessors on a CacheProxyConnection whose underlying connection is a plain Connection (not maintenance-enabled). _get_socket checks isinstance(_conn, MaintNotificationsAbstractConnection) and raises otherwise.
Common situations: Wrapping a basic connection with the cache proxy and then invoking maintenance-notification APIs; mixing CSC with a connection type that was not built for maintenance notifications.
Related errors
- Maintenance notifications handlers on connection are only su
- Maintenance notifications are only supported with RESP versi
- Maintenance notifications are only supported with hiredis an
- To configure maintenance notifications, a parser must be pro
- Cannot enable maintenance notifications for connection objec
AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04).
Data as JSON: /data/errors/1f54eb43f1eaa145.json.
Report an issue: GitHub.