繁体   English   中英

python twilio HTTPSConnectionPool(host='api.twilio.com', port=443) url 超过最大重试次数

[英]python twilio HTTPSConnectionPool(host='api.twilio.com', port=443) Max retries exceeded with url

sid = "*****************************"
token = "*****************************"
client = Client(sid, token)
message = client.messages.create(to="+91**********", from_="+12********", body="Hello from twilio")

在运行上面的代码片段时,我收到错误消息:

ssl.SSLError: [SSL: UNKNOWN_PROTOCOL] 未知协议

我正在使用python3.4的虚拟环境运行它。 我不确定这里出了什么问题。

Twilio 开发人员布道者在这里。

我在这里不完全确定,但我认为您的 TLS 支持可能已经过时。 我使用的是答案而不是评论,因为这会占用更多空间。

您可以尝试从您的 ubuntu vm 运行以下 python 程序并报告结果:

import requests;
print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version']);

编辑

好的,这不是问题,尽管您可以提出某种请求。 你能对requests和 Twilio 端点做同样的事情吗? 类似的东西:

import requests;
request = requests.get('https://api.twilio.com/2010-04-01/Accounts/YOUR_ACCOUNT_SID/Messages.json', auth=('YOUR_ACCOUNT_SID', 'YOUR_AUTH_TOKEN'));
print request.json();

这是关于通过 http 服务器发送请求,我也收到此错误

答案可在https://help.pythonanywhere.com/pages/TwilioBehindTheProxy 上找到

import os
from twilio.rest import Client
from twilio.http.http_client import TwilioHttpClient

proxy_client = TwilioHttpClient(proxy={'http': os.environ['http_proxy'], 'https': os.environ['https_proxy']})

account_sid = 'your account id here'
auth_token = 'your twilio token here'

client = Client(account_sid, auth_token, http_client=proxy_client)

# twilio api calls will now work from behind the proxy:
message = client.messages.create(to="...", from_='...', body='...')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM