Don't ask how, but I parsed the server endpoints of over 5000 nordvpn servers. They usually are something like ar15.nordvpn.com for example. I'm trying to use nordvpn servers as request proxies. I know its possible because nordvpn has a tutorial in setting it up the same way in browsers using port 80. Nordvpn only allows 6 simultaneous connections at the same time. My problem is that what im doing is for each server, i will send a request with that vpn proxy. After the request is sent it finishes. But for some reason even after the request finished the vpn connection somehow seams to be still connected because after the 6th request it fails. I know nordvpn only allows 6 connections at a time but this is one connection after another. The weirdest part is that they immediately go through again after i restart the script(until it reaches the 6th request). So its not nordvpn rate limiting but somehow requests are keeping an established connection.
What ive tried so far is asking r/learnpython. They were useless.
The python discord got me far but never ultimately solved the problem.
I have specified for the connection to close in the request header and even used request sessions, the with syntex for those sessions, and manually close the sesson even though with
should take care of that. Disabling stream also doesnt do anything.
prox = [imagine a long list of nordvpn servers]
def printip():
# proxy auth according to request docs
prox = {
'https': 'https://[email protected]:password123@{}:80/'.format(i)
}
try:
with requests.Session() as s:
s.headers['Connection'] = 'close'
r = s.get('https://api.myip.com', proxies=prox, stream=False)
print(r.json()['ip'])
s.close()
except Exception as x:
print('bruh')
for i in prox:
# i is the server endpoint
printip()
time.sleep(3)
I expected that the requests would work indefinitely but somehow the vpn connection still stays alive.
with requests.Session(config={'keep_alive': False}) as s:
maybe? – Spiderrequest.get
2.python-requests.org//en/latest/user/advanced/#proxies – Spiderhttps
and couldn't get it to work until switching totcp
orudp
. I tried 8 simultaneous requests in JavaScript and they all went through. – Crinoid