我正在使用messenger bot和pymessenger(这里是链接https://github.com/davidchua/pymessenger)。 有时,当我尝试使用bot.send_text_message()或其他函数之一向用户发送消息以发送python包的消息时,我收到以下错误:
File "C:\Python27\lib\site-packages\pymessenger\bot.py", line 29, in send_text_message
return self._send_payload(payload)
File "C:\Python27\lib\site-packages\pymessenger\bot.py", line 76, in _send_payload
result = requests.post(self.base_url, json=payload).json()
File "C:\Python27\lib\site-packages\requests\api.py", line 111, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 57, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 467, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='graph.facebook.com', port=443): Max retries exceeded with url: /v2.6/me/messages?access_token=<my_token> (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x00000000422A40B8>: Failed to establish a new connection: [Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
我想也许我对Facebook做了太多的请求,但是我只是使用机器人和我正在做的请求数量是一个正常的聊天,所以我想它应该是别的,但我不明白。 我正在使用ngrok进行回调。
答案 0 :(得分:0)
尝试捕获HTTPSConnectionPool异常并查看其args以查看我的意思
之类的详细信息except HTTPSConnectionPool as e:
e.args