【问题标题】:send requests to twitter with `requests` : requests.exceptions.SSLError: [Errno bad handshake] (-1, 'Unexpected EOF’)使用 `requests` 向 twitter 发送请求:requests.exceptions.SSLError: [Errno bad handshake] (-1, 'Unexpected EOF')
【发布时间】:2015-04-08 02:39:20
【问题描述】:

我正在使用 python 包requestshttps://mobile.twitter.com/username/following 发送请求。

起初,我遇到了异常:requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol。为了解决这个问题,我按照solution 编写了一个 SSLAdapter 来指定PROTOCOL_TLSv1

在那之后,我遇到了另一个异常:requests.exceptions.SSLError: [Errno bad handshake] (-1, 'Unexpected EOF’)。而且,我找到了this,但我在同一进程中发送请求和接收数据。

也许我发送请求太快了?

【问题讨论】:

  • 我看到了同样的错误,但不知道为什么。
  • @gabe。当您向mobile.twitter.com 或其他端点发送请求时?
  • @gabe。关于第二个异常requests.exceptions.SSLError: [Errno bad handshake] (-1, 'Unexpected EOF’),我在我的程序中发现了错误。那就是我的程序中存在内存泄漏,当内存耗尽时,程序将挂起并且不再收到响应。所以SSL协议没有正常结束,抛出这个异常。
  • 有趣的@stamaimer -- 我将检查我的程序中的内存泄漏。我在完全不同的 api(不是 twitter)上看到了错误。一定是你说我的程序崩溃并且 SSL 连接没有正确关闭。感谢您的提示!
  • 你是怎么解决这个问题的?

标签: python ssl python-requests


【解决方案1】:

你需要为 apache2 安装 mod_ssl

【讨论】:

    猜你喜欢
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    相关资源
    最近更新 更多