尝试使用Tweepy软件包连接到Twitter Streaming 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/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'])
非常感谢!