2

I ran the code as per the documentation

from uber_rides.session import Session
from uber_rides.client import UberRidesClient

session = Session(server_token=<TOKEN>)
client = UberRidesClient(session)
response = client.get_products(37.77, -122.41)

I am behind a proxy server though. And this following connection error was raised.

Traceback (most recent call last): File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn (self.host, self.port), self.timeout, **extra_kw) File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection raise err File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection sock.connect(sa) ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen chunked=chunked) File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request self._validate_conn(conn) File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn conn.connect() File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 284, in connect conn = self._new_conn() File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn self, "Failed to establish a new connection: %s" % e) requests.packages.urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 423, in send timeout=timeout File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen _stacktrace=sys.exc_info()[2]) File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.uber.com', port=443): Max retries exceeded with url: /v1.2/products?latitude=37.77&longitude=-122.41 (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/client.py", line 124, in get_products return self._api_call('GET', 'v1.2/products', args=args) File "/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/client.py", line 104, in _api_call return request.execute() File "/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/request.py", line 152, in execute return self._send(prepared_request) File "/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/request.py", line 136, in _send response = session.send(prepared_request) File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 609, in send r = adapter.send(request, **kwargs) File "/home/djokester/anaconda3/lib/python3.5/site-packages/requests/adapters.py", line 487, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.uber.com', port=443): Max retries exceeded with url: /v1.2/products?latitude=37.77&longitude=-122.41 (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))

djokester
  • 567
  • 9
  • 20

1 Answers1

1

This will likely help add support for a proxy to the Uber python sdk: How can I open a website with urllib via proxy in Python?

Community
  • 1
  • 1
Dustin Whittle
  • 1,242
  • 7
  • 11
  • I think that even though the first solution can help me, it wouldn't suit my need. If I am trying to build an application or a package that is a really very messy solution. – djokester Apr 25 '17 at 06:53
  • I think this is the only way to configure proxy support for urllib. The rides python sdk uses requests which uses urllib which is the core of the issue. We can add proxy support to the backlog. – Dustin Whittle Apr 26 '17 at 18:12