I've looked at and tried several stack solutions regarding the https requests using a proxy with python, and I've seen the discussions on GitHub.
My impression was that the requests library in python 3 now has support for https requests using a proxy and so I don't understand why mine doesn't work:
import requests
proxydict = {
'http':'http://xx.xx.xx.xxx:5555/',
'https':'https://xx.xx.xxx.xx:5555/'
}
requests.get('https://www.google.co.uk',proxies = proxydict).
When I run this code I get:
ConnectionError: HTTPSConnectionPool(host='www.python.org', port=443):
Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake:
Error([('SSL routines', 'ssl3_get_server_certificate', 'certificate verify failed')],)",),))
I was used a postman proxy to do this.
My http requests with a proxy work fine. Can someone help?
Edit:
I wanted to do this with a corporate proxy so I can't simply use a different proxy. Also, the https addresses work fine in the browser, it's simply when I do a python request with the proxy as described in the documentation that this error occurs.
Thanks.
Hi because your proxy is not working with ssl or your proxy is used try other
from here
https://www.sslproxies.org/
scroll down and you see https proxies
Related
I am using this code:
model = SentenceTransformer('bert-base-nli-mean-tokens')
body = list(data['preprocessedBody'])
bodyEmbedding = model.encode(body, show_progress_bar = True)
However, I am getting this error:
ProxyError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/sentence-transformers/bert-base-nli-mean-tokens (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)'))))
Is there any solution to it?
Thank you for your time
It was simply a proxy issue. I just added https and http and their relative proxy values into system environment in windows.
I am trying to connect to the server doing:
nexus_config = nexuscli.nexus_config.NexusConfig(username=NEXUS_USER,
password=NEXUS_PASSWORD,
url=NEXUS_URL,
x509_verify=True)
nexus_client = nexuscli.nexus_client.NexusClient(config=nexus_config)
print(nexus_client.repositories.list)
But, I get the error:
nexuscli.exception.NexusClientConnectionError: HTTPSConnectionPool(host='my_site.net', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1091)')))
https://nexus3-cli.readthedocs.io/en/latest/nexuscli.html#module-nexuscli.nexus_config
checking the URL using the API endpoing with the requests library and setting validate=False I get a warning and does work.
So I change my code to: x509_verify=True hoping that the same from requests will happen that i will be getting warnings but instead i got.
Is there something I am missing? or maybe there is a bug in the library?
thanks guys.
nexuscli.exception.NexusClientAPIError: <exception str() failed>
You are getting the exception: NexusClientAPIError. According to the documents:
exception nexuscli.exception.NexusClientAPIError Bases: Exception
Unexpected response from Nexus service.
I think your code is fine and the issue with x.509 certificate is resolved and the problem might be on the server's side.
I'm using urllib3 to get the html content of a website via a socks proxy.
Unfortunately this does not work on any website. Running this on a few sites will give me an error.
import urllib3
from urllib3.contrib.socks import SOCKSProxyManager
proxy = SOCKSProxyManager('socks5://myProxyIP:8080')
r = proxy.request('GET', "https://urlofwebsite", preload_content=False)
urllib3.exceptions.MaxRetryError:
SOCKSHTTPSConnectionPool(host='urlofwebsite', port=443): Max retries
exceeded with url: /index.php (Caused by SSLError(SSLError(1, u'[SSL:
UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:727)'),))
I assume this might be an issue with the SSL (or TLS) version the site is using but as I am not the owner of the server I have to edit my script to handle with this.
Is it possible to change the setting in urllib3 to accept this connection?
Thanks!
I'm trying to access a table on factfinder.census.gov via their API.
I've tried the solutions listed here and tried using http, all sorts of variants of this code, etc. In fact, I can't even seem to do a simple get (I'm using python requests) on http://factfinder.census.gov/ at all.
E.g.,
https://factfinder.census.gov/service/data/v1/en/programs/DEC/datasets/10_SF1/tables/GCTPH1/data/0100000US.04000
I had to tack on a user access key (from https://factfinder.census.gov/service/UserAccessKey.html) to get access, and then I could just paste https://factfinder.census.gov/service/data/v1/en/programs/DEC/datasets/10_SF1/tables/GCTPH1/data/0100000US.04000?key=MYKEY and it worked fine in private/incognito mode by just pasting it into my browser url bar)
However, I'm getting
Error
requests.exceptions.SSLError: HTTPSConnectionPool(host='factfinder.census.gov', port=443): Max retries exceeded with url: /service/data/v1/en/programs/DEC/datasets/10_SF1/tables/GCTPH1/data/0100000US.04000?key=MYKEY (Caused by SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:598)'),))
I'd hazard a guess that you're querying the link you posted (http://factfinder.census.gov/) using http not https (notice if you click that link it redirects to https), the site uses SSL encryption and is rejecting the unencrypted connection attempt.
I keep getting the following error intermittently, i'm suspecting a proxy on the network is causing this, since i can run my python script when using a different connection.
I'm using python 2.7 and also using Fiddler to help with the proxy authentication.
SSLError: HTTPSConnectionPool(host='api.bogus.com', port=443): Max
retries exceeded with url: /api/v1/oauth2/token (Caused by
SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected
EOF')",),))
At the moment I am having some limited success with the following setup, it does fail quite often but it manages to work a few times. I am using a session with the following parameters:
def get_session():
session = requests.Session()
# limit connection pool and connection numbers
session.mount('https://', HTTPAdapter(max_retries=5, pool_connections=100, pool_maxsize=100))
# make sure all connections are closed
session.headers.update({"Connection": "close"})
return session