Forums

Problem configuring proxy

Hello,

as a free account user, I'm trying to use pythonanywhere proxy to use cloudinary api.

I'm sorry but I am a total newbie with proxies things... (and I'm french so excuse me for my bad english)

I know there is an http server => proxy.server:3128.

Do I have to put this verbatim ? Or do I have to find values for "proxy" and "server" ?

Because this code in Pyhton doesn't work :

import requests

 proxies = {
       'http': 'proxy.server:3128',
       'https': 'proxy.server:3128',
 }

url='https://####:####@api.cloudinary.com/v1_1/###/resources/image"

resp = requests.get(url, proxies=proxies)

photos = resp.json()

Thank you in advance.

Bertz

Those are the correct proxy settings. In what way does it not work?

Hi, with this config :

proxies = { 'http': 'http://proxy.server:3128', 'https': 'http://proxy.server:3128', }

I got this message :

HTTPSConnectionPool(host='api.cloudinary.com', port=443): Max retries exceeded with url: /v1_1/###/resources/image (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001BCBB2A1400>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')))

Try with proxies = {'http': 'proxy.server:3128', 'https': 'proxy.server:3128'} instead.

Same message :

HTTPSConnectionPool(host='api.cloudinary.com', port=443): Max retries exceeded with url: /v1_1/###/resources/image (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x000001D90C20EBE0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')))

:(

Curiously, this code is ok when I run it in the pythonanywhere bash console. I get the error message only when I run it locally or at myaccount.pythonanywhere.com

Could you try the call without setting proxy? The requests library loads the proxy info from the environment. So the code would look like:

url='https://####:####@api.cloudinary.com/v1_1/###/resources/image"

resp = requests.get(url)

photos = resp.json()

Well, everything is ok now in local. But... it does not work on pythonanywhere.com.

The error message is :

'MaxRetryError' object has no attribute 'message'

Ok, so I've made a new simple site, and all seems to work. I think I have to look for a cleaner code. Thank you, I will make some tries and if I get other problems, I sure will come back. ;)

What is the full traceback?

It seems to be ok, there was a problem in my settings files. No problem for me now, thanks again !

Glad to hear that!