aio-libs / aiodns

Simple DNS resolver for asyncio
https://pypi.python.org/pypi/aiodns
MIT License
532 stars 69 forks source link

SystemError resolving TXT record #32

Closed pin3da closed 7 years ago

pin3da commented 7 years ago

Hello, I was resolving DNS records for some domains and I found an unexpected error resolving the TXT record of like.com.sa

Here is a code to reproduce the error

import asyncio
import aiodns

loop = asyncio.get_event_loop()
resolver = aiodns.DNSResolver(loop=loop)
result = loop.run_until_complete(resolver.query('like.com.sa', 'TXT'))
print(result)

Thanks

saghul commented 7 years ago

What error do you get?

pin3da commented 7 years ago
Exception ignored in: functools.partial(<function DNSResolver._callback at 0x7fc615986950>, <Future pending cb=[_run_until_complete_cb() at /usr/local/lib/python3.6/asyncio/base_events.py:176]>)
Traceback (most recent call last):
  File "/home/pin3da/py-envs/py36-discovery/lib/python3.6/site-packages/aiodns/__init__.py", line 56, in _callback
    if fut.cancelled():
SystemError: <built-in method cancelled of _asyncio.Future object at 0x7fc615ebbcf8> returned a result with an error set
saghul commented 7 years ago

Hi there! I could reproduce it. It seems to only happen with that domain, as tests pass. I'll take a look as soon as I can!

saghul commented 7 years ago

I think the problem is in pycares.

pin3da commented 7 years ago

I found another domain which causes the same problem (maybe helps to see what happens):

wide.com.es

saghul commented 7 years ago

Thanks!

saghul commented 7 years ago

This should fix it: https://github.com/saghul/pycares/pull/57

saghul commented 7 years ago

Tests pass, this will be part of the next pycares release. You can alternatively install pycares from master in the meantime. Cheers!

pin3da commented 7 years ago

It's working now, thank you very much !

steven2308 commented 6 years ago

Hi, I have the exact problem just with another domain and MX:

import asyncio
import aiodns

loop = asyncio.get_event_loop()
resolver = aiodns.DNSResolver(loop=loop)
result = loop.run_until_complete(resolver.query('xn--cardeosapeluqueros-r0b.com', 'MX'))
print(result)

I get Exception ignored in: functools.partial(<function DNSResolver._callback at 0x7fc89b406ea0>, <Future pending cb=[_run_until_complete_cb() at /usr/local/lib/python3.6/asyncio/base_events.py:176]>) Traceback (most recent call last): File "/home/steven/Envs/vPandapipe/lib/python3.6/site-packages/aiodns/__init__.py", line 56, in _callback if fut.cancelled(): SystemError: <built-in method cancelled of _asyncio.Future object at 0x7fc89bb3b828> returned a result with an error set

I'm using aiodns 1.1.1 and pycares 2.3.0. Should I create a new issue?

steven2308 commented 6 years ago

Doing a ns lookup I found this for MX: Non-authoritative answer: xn--cardeosapeluqueros-r0b.com mail exchanger = 10 carde\241osapeluqueros.com. Maybe it's the special character "\241"?

Found another case with SOA for ayesas.com. Its record also contains a special character:

ayesas.com
    origin = ns2.3c1b.com
    mail addr = adm\253n.domain.com
    serial = 2015010244
    refresh = 3600
    retry = 600
    expire = 1209600
    minimum = 3600

I think the origin of the problem is different so I'm creating a new issue.