python - 'NoneType' 对象在 scrapy\twisted\openssl 中没有属性 '_app_data'

标签 python openssl scrapy twisted pyopenssl

在使用 scrapy 进行抓取的过程中,我的日志中时不时出现一个错误。 它似乎不在我的代码中的任何地方,看起来像是 twisted\openssl 中的东西。 知道是什么原因造成的以及如何摆脱它吗?

此处的堆栈跟踪:

[Launcher,27487/stderr] Error during info_callback
    Traceback (most recent call last):
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/twisted/protocols/tls.py", line 415, in dataReceived
        self._write(bytes)
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/twisted/protocols/tls.py", line 554, in _write
        sent = self._tlsConnection.send(toSend)
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1270, in send
        result = _lib.SSL_write(self._ssl, buf, len(buf))
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/OpenSSL/SSL.py", line 926, in wrapper
        callback(Connection._reverse_mapping[ssl], where, return_code)
    --- <exception caught here> ---
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 1055, in infoCallback
        return wrapped(connection, where, ret)
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/twisted/internet/_sslverify.py", line 1157, in _identityVerifyingInfoCallback
        transport = connection.get_app_data()
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1589, in get_app_data
        return self._app_data
      File "/opt/webapps/link_crawler/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1148, in __getattr__
        return getattr(self._socket, name)
    exceptions.AttributeError: 'NoneType' object has no attribute '_app_data'

最佳答案

我能够通过安装 service_identity 包解决这个问题:

pip install service_identity

关于python - 'NoneType' 对象在 scrapy\twisted\openssl 中没有属性 '_app_data',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30202669/

相关文章:

c++ - POCO : Concurrent access to SecureStreamSocket

python - Scrapy - 没有名为 mail.smtp 的模块

python - 除了循环之外还有其他方法可以从任何序列数据(Python)更新字典吗?

python - 使用 Python 的 Windows 桌面 GUI 自动化—— sleep 与紧循环

ruby-on-rails - http 方: `connect':连接被对等方重置 - SSL_connect (Errno::ECONNRESET)

ruby-on-rails - Puma::MiniSSL::SSLError: OpenSSL error: error:1417A0C1:SSL routines:tls_post_process_client_hello:no shared cipher rails

python - Scrapy不同数量的url返回

python - python的scrapy如何使用css选择器提取url?

python - 如何重写这个字典定义以使 PyCharm 不发出警告?

python - Django Rest 框架 JWT