Forums

Configure Proxy Connection

Upon first running my code I revived this error attempting to connect to "api-free.deepl.com" which is included on the free whitelist :

Traceback (most recent call last):
  File "/home/Jaxkey/.local/lib/python3.9/site-packages/deepl/http_client.py", line 168, in _internal_request
    response = self._session.send(
  File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api-free.deepl.com', port=443): Max retries exceeded with url: /v2/translate (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection ob
ject at 0x7f6d709f60a0>: Failed to establish a new connection: [Errno 111] Connection refused'))

On this guide it describes manually configuring a proxy connection which you can do through DeepL's API using

deepl.Translator('API KEY', proxy='PROXY')

so I figured that may solve the issue. What should I actually put in for the PythonAnywhere proxy? I see it says "proxy.server:3128" in the guide, however I don't know what that means or how to implement it correctly.

Thank you for the help!

Try using 'http://proxy.server:3128' as a value of the proxy kwarg.

That did the trick! Thanks for the help!

Glad to hear that!

Hi, I am trying to integrate telegram. I know 'api.telegram.org' is whitelisted. I also configured the proxy, still getting the error.

import telepot
from time import sleep

TOKEN = ****
receiver = ****
telepot.api.set_proxy( 'http://proxy.server:3128')
bot = telepot.Bot(TOKEN)

for i in range(1200):
    bot.sendMessage(receiver, str(i))
    sleep(5)

but I'm still getting the error:

Traceback (most recent call last):
 File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 158, in _new_conn
conn = connection.create_connection(
 File "/usr/lib/python3.8/site-packages/urllib3/util/connection.py", line 80, in create_connection
raise err
 File "/usr/lib/python3.8/site-packages/urllib3/util/connection.py", line 70, in create_connection
sock.connect(sa)
 OSError: [Errno 101] Network is unreachable

Check docs of the library you are using and make sure that that's a correct configuration.

For people trying to use the "v3.football.api-sports.io" API. In order to configure according to the libraries http.client, you might need:

proxy_server = 'proxy.server' proxy_port = 3128

  1. conn = http.client.HTTPSConnection(proxy_server, proxy_port) ->> setting the proxy

  2. conn.set_tunnel('v3.football.api-sports.io') ->> setting the destination

The rest remains the same.

Thanks for posting that!