Python 尝试连接到Twitter流式API时出现SSL错误
我在尝试使用Tweepy包连接到Twitter流媒体API时遇到了一些SSL错误。我了解到SSL证书无效,但我无法解决这个问题。奇怪的是,有时它工作正常,有时不正常,甚至不涉及代码。 这是我的错误日志:Python 尝试连接到Twitter流式API时出现SSL错误,python,ssl,twitter,openssl,tweepy,Python,Ssl,Twitter,Openssl,Tweepy,我在尝试使用Tweepy包连接到Twitter流媒体API时遇到了一些SSL错误。我了解到SSL证书无效,但我无法解决这个问题。奇怪的是,有时它工作正常,有时不正常,甚至不涉及代码。 这是我的错误日志: File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/Library/
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/streaming.py", line 299, in filter
self._start(async)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/streaming.py", line 236, in _start
self._run()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/streaming.py", line 157, in _run
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1176, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 387, in wrap_socket
ciphers=ciphers)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 143, in __init__
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 305, in do_handshake
self._sslobj.do_handshake()
SSLError: [Errno 8] _ssl.c:507: EOF occurred in violation of protocol
我使用的是典型的连接方式:
# Authentification
auth = OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token (access_token, access_token_secret)
# Connecting to the stream
twitterStream = Stream (auth, twitterListener())
twitterStream.filter(track=['someWord'])
非常感谢 也许这有帮助:是的,正在调用ssl.wrap_socket()。我的回答会有帮助