2017-04-24 93 views
2

我跑的代碼,每個文檔爲什麼我無法建立與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',))

回答

1

這可能會有助於增加對代理尤伯杯的Python SDK支持:How can I open a website with urllib via proxy in Python?

+0

我認爲,即使第一個解決方案可以幫助我,那就不適合我的需要。如果我正在嘗試構建一個真正非常混亂的解決方案的應用程序或包。 – Djokester

+0

我認爲這是爲urllib配置代理支持的唯一方法。遊戲機python sdk使用使用urllib的請求,這是問題的核心。我們可以爲積壓添加代理支持。 –