Problem solving SSL: WRONG_VERSION_NUMBER

Viewed 1274

I am trying to create a program using asyncio and aiohttp to test certain features of my website such as filling out forms and gathering cookies. I am testing it with the use of proxies and just getting it to visit my page and check if there is something I placed in the HTML, but I keep getting errors such as:

15:01:29.600 SSL error in data received
protocol: <asyncio.sslproto.SSLProtocol object at 0x0873A0B0>
transport: <_SelectorSocketTransport fd=1492 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "C:\Users\x\AppData\Local\Programs\Python\Python37-32\lib\asyncio\sslproto.py", line 526, in data_received
    ssldata, appdata = self._sslpipe.feed_ssldata(data)
  File "C:\Users\x\AppData\Local\Programs\Python\Python37-32\lib\asyncio\sslproto.py", line 207, in feed_ssldata
    self._sslobj.unwrap()
  File "C:\Users\x\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 767, in unwrap
    return self._sslobj.shutdown()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2609)

It doesn't happen to every instance I launch, but it happens to a lot of them. Here is my code

import asyncio
import ClientSession from aiohttp

def main():
    tasks = []
    loop = asyncio.get_event_loop()
    for i in range(10):
        task = asyncio.ensure_future(launch(url, ip, port))
        tasks.append(task)
    loop.run_until_complete(asyncio.wait(tasks))


async def launch(url, ip, port):
    done = False
    proxy = "http://{}:{}".format(ip, port)
    async with ClientSession() as session:
        while not done:
            async with session.get(url, timeout=40, proxy=proxy) as initial:
                html_text = await initial.text()
                if x in html_text:
                    done = True
                else:
                    asyncio.sleep(60)
        await session.close()

if __name__ == "__main__":
    main()

The proxies are just HTTP proxies.

If anyone could help me solve this it would be really useful, thank you.

EDIT: My website is HTTPS if it makes a difference.

EDIT2: For more clarification, they all work for a bit and keep refreshing, but then they all just start dying one by one

EDIT3: After making it print all errors, I am also getting this error:

Cannot connect to host domain:[prt ssl:None [Connect call failed ('IP', Port)]

0 Answers
Related