Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncResolver cannot resolve names if resolv.conf is not in the normal location #10519

Open
1 task done
Heporis opened this issue Mar 5, 2025 · 8 comments · May be fixed by #10543
Open
1 task done

AsyncResolver cannot resolve names if resolv.conf is not in the normal location #10519

Heporis opened this issue Mar 5, 2025 · 8 comments · May be fixed by #10543
Labels
bug needs-info Issue is lacking sufficient information and will be closed if not provided

Comments

@Heporis
Copy link

Heporis commented Mar 5, 2025

Describe the bug

I'm using a program biliup in termux.
The web content doesn't display with aiohttp > 3.9.5. when I downgrade aiohttp to 3.9.5, it appears.
It only occurs in termux.

1.mp4

Image

To Reproduce

  1. Install biliup in termux with the guide
  2. Open the webUI(0.0.0.0:19159/upload-manager) to login bilibili account.
  3. Although login successful, there is no account(as in the video).
  4. Downgrade aiohttp to 3.9.5, and the account appears(as in the picture).

Expected behavior

appears

Logs/tracebacks

no

Python Version

3.12.9

aiohttp Version

3.11.13

multidict Version

6.1.0

propcache Version

0.3.0

yarl Version

1.18.3

OS

termux Android

Related component

Server

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@Heporis Heporis added the bug label Mar 5, 2025
@Dreamsorcerer
Copy link
Member

That's not really a useful bug report. You'll need to report the issue to the project that is failing or provide an exception for us to know if there's any issue with aiohttp.

The only obvious thing in the changelog is that cookie formats changed, so if they are storing cookies somewhere and then trying to use filter_cookies(), those cookies would need to be migrated to the new format (or simply recreated):
https://github.com/aio-libs/aiohttp/releases/tag/v3.10.0

@Dreamsorcerer Dreamsorcerer added the needs-info Issue is lacking sufficient information and will be closed if not provided label Mar 6, 2025
@xxxxuanran
Copy link

I created a script to test the issue:

from aiohttp.client import ClientSession
import asyncio
import httpx
async def proxy():
    url = "https://i0.hdslb.com/bfs/face/member/noface.jpg"
    print("aiohttp")
    try:
        async with ClientSession() as session:
            async with session.get(url) as res1:
                print(res1.status)
    except Exception as e:
        print(e)
    print("httpx")
    try:
        async with httpx.AsyncClient() as client:
            res2 = await client.get(url)
            print(res2.status_code)
    except Exception as e:
        print(e)

if __name__ == '__main__':
    asyncio.run(proxy())

The environment for running this script is: Python 3.12.9, aiohttp 3.11.13, aiodns 3.2.0.
After running this script, I encountered a DNSError from aiodns. The full error message has been pasted here: https://paste.ubuntu.com/p/h56ZsTDcQZ/.

After reviewing the commit history, I believe this issue might be related to this commit: Commit 5a9e500.

So, I tried removing the aiodns module and reran the test script. This time, I was able to get the expected status codes:

python test.py
aiohttp
200
httpx
200

@bdraco
Copy link
Member

bdraco commented Mar 6, 2025

Check that your /etc/resolv.conf is configured correctly. If you are using a non-unix like OS, the other potential files to check are seen in:

https://github.com/c-ares/c-ares/blob/7978cf75a82f9860da241227169a4d7f1d1f549a/src/lib/ares_private.h#L124

@Heporis
Copy link
Author

Heporis commented Mar 7, 2025

Check that your /etc/resolv.conf is configured correctly. If you are using a non-unix like OS, the other potential files to check are seen in:

https://github.com/c-ares/c-ares/blob/7978cf75a82f9860da241227169a4d7f1d1f549a/src/lib/ares_private.h#L124

The running environment is Termux-app on Android.
If you mean resolv.conf in termux:
/data/data/com.termux/files/usr/etc/resolv.conf:

nameserver 8.8.8.8
nameserver 8.8.4.4

@bdraco
Copy link
Member

bdraco commented Mar 7, 2025

c-ares likely doesn't know how to find the resolv.conf on your platform since it's not in the normal place.

You can workaround the issue by symlinking it or changing to ThreadedResolver

It would be nice to open an issue for c-ares as well.

We might be able to be a bit smarter about it an auto fallback to threaded resolver if async resolver can't find any servers

@bdraco bdraco changed the title The web content doesn't display with aiohttp > 3.9.5 AsyncResolver cannot resolve names if resolv.conf is not in the normal location Mar 7, 2025
@Heporis
Copy link
Author

Heporis commented Mar 13, 2025

c-ares/c-ares#964

@bdraco
Copy link
Member

bdraco commented Mar 13, 2025

It looks like google shot down exposing the nameserver list in https://issuetracker.google.com/issues/351660510#comment4

@bdraco
Copy link
Member

bdraco commented Mar 13, 2025

@Heporis What does the following show on your system?
python3 -c 'import pycares; print(bool(pycares.Channel().servers))'

@bdraco bdraco linked a pull request Mar 13, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-info Issue is lacking sufficient information and will be closed if not provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants