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

时间:2017-04-24 15:49:05

标签: python api proxy 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(最近一次调用最后一次):文件   “/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py”   第141行,在_new_conn中       (self.host,self.port),self.timeout,** extra_kw)文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py”,   第83行,在create_connection中       提出错误文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/connection.py”,   第73行,在create_connection中       sock.connect(sa)ConnectionRefusedError:[Errno 111]拒绝连接

     

在处理上述异常期间,发生了另一个异常:

     

Traceback(最近一次调用最后一次):文件   “/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py”   第600行,在urlopen       chunked = chunked)文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py”,   第37行,在_make_request中       self._validate_conn(conn)文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py”,   第844行,在_validate_conn中       conn.connect()文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py”,   第284行,在连接中       conn = self._new_conn()文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connection.py”,   第150行,在_new_conn中       self,“无法建立新连接:%s”%e)requests.packages.urllib3.exceptions.NewConnectionError:   :无法建立新连接:[Errno 111]   连接被拒绝

     

在处理上述异常期间,发生了另一个异常:

     

Traceback(最近一次调用最后一次):文件   “/home/djokester/anaconda3/lib/python3.5/site-packages/requests/adapters.py”   第423行,发送       timeout = timeout文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/connectionpool.py”,   第649行,在urlopen中       _stacktrace = sys.exc_info()[2])文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/packages/urllib3/util/retry.py”,   第376行,增量       引发MaxRetryError(_pool,url,error或ResponseError(cause))requests.packages.urllib3.exceptions.MaxRetryError:   HTTPSConnectionPool(host ='api.uber.com',port = 443):最大重试次数   超过网址:/v1.2/products ?latitude = 37.77&amp ;longitude = 1222.41   (引起的   NewConnectionError(':无法建立新连接:   [Errno 111]连接拒绝',))

     

在处理上述异常期间,发生了另一个异常:

     

Traceback(最近一次调用最后一次):文件“”,第1行,in      文件   “/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/client.py”   第124行,在get_products中       return self._api_call('GET','v1.2 / products',args = args)文件“/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/client.py”,   第104行,在_api_call中       return request.execute()文件“/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/request.py”,   第152行,执行中       return self._send(prepared_request)文件“/home/djokester/anaconda3/lib/python3.5/site-packages/uber_rides/request.py”,   第136行,在_send       response = session.send(prepared_request)文件“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/sessions.py”,   第609行,发送       r = adapter.send(request,** kwargs)File“/home/djokester/anaconda3/lib/python3.5/site-packages/requests/adapters.py”,   第487行,发送       引发ConnectionError(e,request = request)requests.exceptions.ConnectionError:   HTTPSConnectionPool(host ='api.uber.com',port = 443):最大重试次数   超过网址:/v1.2/products ?latitude = 37.77&amp ;longitude = 1222.41   (引起的   NewConnectionError(':无法建立新连接:   [Errno 111]连接拒绝',))

1 个答案:

答案 0 :(得分:1)

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