NanmiCoder/MediaCrawler · error

[BaiduTieBaClient.get] Reached maximum retry attempts, IP is

Error message

[BaiduTieBaClient.get] Reached maximum retry attempts, IP is blocked, please try a new IP proxy: {e}

What it means

Raised by BaiduTieBaClient.get (media_platform/tieba/client.py:305) when the wrapped request exhausts all retry attempts (tenacity RetryError) and no IP pool is configured to fail over to a fresh proxy. The method catches RetryError, tries self.ip_pool.get_proxy(); only if that is unavailable does it log and re-raise. It means sustained request failure, most commonly IP-level blocking, not a transient glitch.

Source

Thrown at media_platform/tieba/client.py:305

        """
        final_uri = uri
        if isinstance(params, dict):
            final_uri = (f"{uri}?"
                         f"{urlencode(params)}")
        try:
            res = await self.request(method="GET", url=f"{self._host}{final_uri}", return_ori_content=return_ori_content, **kwargs)
            return res
        except RetryError as e:
            if self.ip_pool:
                proxie_model = await self.ip_pool.get_proxy()
                _, proxy = utils.format_proxy_info(proxie_model)
                res = await self.request(method="GET", url=f"{self._host}{final_uri}", return_ori_content=return_ori_content, proxy=proxy, **kwargs)
                self.default_ip_proxy = proxy
                return res

            utils.logger.error(f"[BaiduTieBaClient.get] Reached maximum retry attempts, IP is blocked, please try a new IP proxy: {e}")
            raise Exception(f"[BaiduTieBaClient.get] Reached maximum retry attempts, IP is blocked, please try a new IP proxy: {e}")

    async def post(self, uri: str, data: dict, **kwargs) -> Dict:
        """
        POST request with header signing
        Args:
            uri: Request route
            data: Request body parameters

        Returns:

        """
        json_str = json.dumps(data, separators=(',', ':'), ensure_ascii=False)
        return await self.request(method="POST", url=f"{self._host}{uri}", data=json_str, **kwargs)

    async def pong(self, browser_context: BrowserContext = None) -> bool:
        """
        Check if login state is still valid
        Uses Cookie detection instead of API calls to avoid detection

View on GitHub (pinned to d6f7c5bb90)

Solutions

  1. Configure an IP proxy pool on BaiduTieBaClient so the RetryError fallback path can rotate IPs
  2. Reduce request rate (CRAWLER_MAX_SLEEP_SEC, crawl_interval) to avoid triggering the block in the first place
  3. Restart the crawl from a different network/IP after the block cools down
  4. Refresh cookies via re-login if the block is account-bound rather than IP-bound

Example fix

# before
client = BaiduTieBaClient()  # no ip_pool

# after
from proxy import IpPool  # project proxy provider
ip_pool = IpPool()
client = BaiduTieBaClient(ip_pool=ip_pool)
Defensive patterns

Strategy: fallback

Validate before calling

if client.ip_pool is None:
    # every retry will hit the same IP; configure a pool or slow down before starting
    set_higher_crawl_interval()

Try / catch

from tenacity import RetryError

try:
    res = await client.get(uri, params=params)
except RetryError as e:
    raise RuntimeError("Tieba rate-limited this IP; configure ip_pool or change IP") from e

Prevention

When it happens

Trigger: A GET request failing repeatedly until the tenacity retry budget is exhausted, with self.ip_pool falsy (no proxy pool configured). With an ip_pool present the code silently retries via a proxy instead; the exception only surfaces when there is nowhere else to route.

Common situations: Default configuration without proxy support; long-running crawls whose egress IP eventually gets blocklisted; rate limiting combined with retries that all hit the same blocked IP.

Related errors


AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15). Data as JSON: /api/errors/acf8c34cce6e4347. Report an issue: GitHub.