I'm trying to lookup about 10,000 domains via whois with the following code.
async def lookup(server, port, query, sema):
async with sema as sema:
try:
reader, writer = await asyncio.open_connection(server, port)
except:
return {}
writer.write(query.encode("ISO-8859-1"))
await writer.drain()
data = b""
while True:
d = await reader.read(4096)
if not d:
break
data += d
writer.close()
data = data.decode("ISO-8859-1")
return data
However I repeatedly get the error 'Connect Failed'. If I try a single lookup it goes through which means the whois server is up. I've also increased the ulimit to 10,000 but I'm limiting lookups to only a 1000 at a time with a semaphore.