Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shaun-ba opened this issue Nov 6, 2015 · 6 comments

Comments

@shaun-ba
Copy link

shaun-ba commented Nov 6, 2015

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

@michaelhelmick
Copy link
Collaborator

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.

@shaun-ba
Copy link
Author

shaun-ba commented Nov 8, 2015

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?

@michaelhelmick michaelhelmick reopened this Nov 9, 2015
@michaelhelmick
Copy link
Collaborator

@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 :(

@shaun-ba
Copy link
Author

shaun-ba commented Nov 9, 2015

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

@vionemc
Copy link

vionemc commented Dec 22, 2015

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?

@navchandar
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants