default_failure_handler

Documentation for eth_defi.provider.rpc_proxy.default_failure_handler function.

default_failure_handler(http_status, json_body)

Default failure detection replicating eth_defi.middleware logic.

Adapted from eth_defi.middleware.is_retryable_http_exception() and eth_defi.provider.fallback.FallbackProvider to work at the HTTP proxy level with raw status codes and JSON bodies rather than Python exceptions.

The checks are, in order:

  1. HTTP status code against eth_defi.middleware.DEFAULT_RETRYABLE_HTTP_STATUS_CODES

  2. JSON-RPC error.code against eth_defi.middleware.DEFAULT_RETRYABLE_RPC_ERROR_CODES

  3. JSON-RPC error.message substring match against eth_defi.middleware.DEFAULT_RETRYABLE_RPC_ERROR_MESSAGES

Connection-level failures (timeouts, refused connections) are always retried and never reach this handler — they are caught earlier in _ProxyRequestHandler._try_upstream().

Parameters
  • http_status (int) – HTTP response status code from the upstream provider.

  • json_body (Optional[dict]) – Parsed JSON-RPC response body, or None if unparseable.

Returns

True if the response should be treated as a retryable failure.

Return type

bool