I created a twitter monitor and it works fine but after a while the program crashes with the follow error
File "/home/server/.local/lib/python3.6/site-packages/urllib3/response.py", line 380, in _error_catcher
raise ProtocolError('Connection broken: %r' % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(10 bytes read)', IncompleteRead(10 bytes read))
File "/home/server/.local/lib/python3.6/site-packages/urllib3/response.py", line 380, in _error_catcher
raise ProtocolError('Connection broken: %r' % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(10 bytes read)', IncompleteRead(10 bytes read))
Heres my listener function, i also put the following catch errors but its not doing anything
from http.client import IncompleteRead as http_incompleteRead
from urllib3.exceptions import IncompleteRead as urllib3_incompleteRead
def Create_Listner():
monitor_down('Started Twitter Bot Successfully!')
listener = StreamPrinter()
auth = OAuthHandler(Consumer_Key, Consumer_Secret)
auth.set_access_token(Access_Token, Access_Token_Secret)
#api = tweepy.API(auth, wait_on_rate_limit=True, wait_on_rate_limit_notify=True)
stream = Stream(auth, listener)
try:
stream.filter(follow=['3295423333', '59393368', '14886375'], is_async=True)
except http_incompleteRead as e:
#stream.disconnect()
print("\n~~~ Restarting stream in 5 seconds... ~~~")
monitor_down('Bot Crashed! Restarting Bot')
time.sleep(5)
except urllib3_incompleteRead as e:
print("\n~~~ Restarting stream in 5 seconds... ~~~")
monitor_down('Bot Crashed! Restarting Bot')
time.sleep(5)