twython icon indicating copy to clipboard operation
twython copied to clipboard

TwythonError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded

Open shaun-ba opened this issue 10 years ago • 6 comments

full trace:

2015-11-03 20:58:35,912 urllib3.connectionpool [DEBUG] :: Setting read timeout to None Traceback (most recent call last): File "file", line 29, in twitter.update_status_with_media(media=photo, status=status) File "file", line 130, in update_status_with_media return self.post('statuses/update_with_media', params=params) File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 269, in post return self.request(endpoint, 'POST', params=params, version=version) File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 259, in request api_call=url) File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 165, in request raise TwythonError(str(e)) twython.exceptions.TwythonError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update with_media.json (Caused by <class 'socket.error'>: [Errno 110] Connection timed out)

Code thats using the twython function:

http://pastebin.com/aPnrSdVy

shaun-ba avatar Nov 06 '15 18:11 shaun-ba

You're sending too many requests from the same IP address, causing api.twitter.com to refuse the connection. There really isn't much you can do except try in a few minutes after the error.

michaelhelmick avatar Nov 07 '15 15:11 michaelhelmick

No, i'm not.

I'm sending one request per 4 hours. If i catch this error and retry 5seconds later it works just fine..

edit: where in my code do you see i'm making too many requests exactly?

shaun-ba avatar Nov 08 '15 10:11 shaun-ba

@bitnumus didn't mean to close this, sorry! And I don't see you making too many requests. Is the error still occurring?

I could be twitter acting up?

I just tested this and had no issues :(

michaelhelmick avatar Nov 09 '15 14:11 michaelhelmick

No its happening every time, at the moment i'm catching the error and retrying, it succeeds on retry. As a guess could it be related to keepalive?

2015-11-09 05:46:34,955 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 05:46:35,261 urllib3.connectionpool [DEBUG] :: "POST /1.1/media/upload.json HTTP/1.1" 200 143 2015-11-09 05:46:35,265 urllib3.connectionpool [INFO] :: Resetting dropped connection: api.twitter.com 2015-11-09 05:46:35,585 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 05:46:36,007 urllib3.connectionpool [DEBUG] :: "POST /1.1/statuses/update.json HTTP/1.1" 200 1162 2015-11-09 09:46:36,115 urllib3.connectionpool [INFO] :: Resetting dropped connection: upload.twitter.com 2015-11-09 09:46:36,471 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 09:46:36,730 urllib3.connectionpool [DEBUG] :: "POST /1.1/media/upload.json HTTP/1.1" 200 143 2015-11-09 09:46:36,734 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 10:03:14,672 twitter_daemon [ERROR] :: twitter call failed Traceback (most recent call last): File "", line 36, in twitter.update_status(status=status, media_ids=[response['media_id']]) File "/usr/local/lib/python2.7/dist-packages/twython/endpoints.py", line 107, in update_status return self.post('statuses/update', params=params) File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 269, in post return self.request(endpoint, 'POST', params=params, version=version) File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 259, in request api_call=url) File "/usr/local/lib/python2.7/dist-packages/twython/api.py", line 165, in _request raise TwythonError(str(e)) TwythonError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/update.json (Caused by <class 'socket.error'>: [Errno 110] Connection timed out) 2015-11-09 10:03:29,700 urllib3.connectionpool [INFO] :: Resetting dropped connection: upload.twitter.com 2015-11-09 10:03:30,046 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 10:03:30,490 urllib3.connectionpool [DEBUG] :: "POST /1.1/media/upload.json HTTP/1.1" 200 142 2015-11-09 10:03:30,501 urllib3.connectionpool [INFO] :: Starting new HTTPS connection (8): api.twitter.com 2015-11-09 10:03:30,831 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 10:03:31,186 urllib3.connectionpool [DEBUG] :: "POST /1.1/statuses/update.json HTTP/1.1" 200 1161 2015-11-09 14:03:31,290 urllib3.connectionpool [INFO] :: Resetting dropped connection: upload.twitter.com 2015-11-09 14:03:31,639 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 14:03:31,894 urllib3.connectionpool [DEBUG] :: "POST /1.1/media/upload.json HTTP/1.1" 200 143 2015-11-09 14:03:31,897 urllib3.connectionpool [INFO] :: Resetting dropped connection: api.twitter.com 2015-11-09 14:03:32,227 urllib3.connectionpool [DEBUG] :: Setting read timeout to None 2015-11-09 14:03:32,698 urllib3.connectionpool [DEBUG] :: "POST /1.1/statuses/update.json HTTP/1.1" 200 1161

shaun-ba avatar Nov 09 '15 14:11 shaun-ba

I also got this error if I run twython request from APScheduler. @bitnumus do you also use any scheduler or run twython in a thread?

vionemc avatar Dec 22 '15 13:12 vionemc

I just ran Twython for the first time and got this error.

navchandar avatar Mar 02 '19 14:03 navchandar