aiohttp-asyncmdnsresolver is an asynchronous resolver for aiohttp that extends its capabilities to include mDNS (multicast DNS) resolution. It leverages the zeroconf library to resolve '.local' domain names. The library is actively maintained by the aio-libs organization, with its current version being 0.1.1, and typically sees releases aligned with updates to aiohttp or zeroconf, or as new features and fixes are introduced.
pip install aiohttp-asyncmdnsresolverVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `aiohttp-asyncmdnsresolver` with `aiohttp.ClientSession` to enable both mDNS (`.local` hostnames) and standard DNS resolution. It uses `AsyncDualMDNSResolver` which attempts mDNS first and falls back to regular DNS, providing comprehensive hostname resolution. Remember to replace `mydevice.local.` with an actual mDNS-resolvable host on your network for testing mDNS.
Use `aiohttp_asyncmdnsresolver.api.AsyncMDNSResolver` or `AsyncDualMDNSResolver` with `aiohttp.TCPConnector`.
For comprehensive resolution, import and use `aiohttp_asyncmdnsresolver.api.AsyncDualMDNSResolver`.
Ensure your environment's `setuptools` is updated to version 77+ before upgrading to `aiohttp-asyncmdnsresolver` v0.1.2 or later.
Configure `aiohttp.TCPConnector` to use a resolver from `aiohttp-asyncmdnsresolver`, such as `AsyncDualMDNSResolver`, when creating your `aiohttp.ClientSession`.
Explicitly override the `aiohttp.TCPConnector`'s resolver with `aiohttp_asyncmdnsresolver.api.AsyncMDNSResolver` or `AsyncDualMDNSResolver` to ensure mDNS capabilities.
For environments where you need to resolve both mDNS (`.local`) and standard DNS hostnames reliably, use `aiohttp_asyncmdnsresolver.api.AsyncDualMDNSResolver`.