为什么我无法与 Uber API 建立连接?

Why can't I establish a connection to the Uber API?

我运行 文档中的代码

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)

虽然我在代理服务器后面。并引发了以下连接错误。

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',))

这可能有助于为 Uber python sdk 添加对代理的支持:How can I open a website with urllib via proxy in Python?