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

Error HTTP 502 in long polling (bot.getUpdates) #40

Closed
yogch opened this issue Aug 18, 2015 · 4 comments
Closed

Error HTTP 502 in long polling (bot.getUpdates) #40

yogch opened this issue Aug 18, 2015 · 4 comments
Assignees
Labels

Comments

@yogch
Copy link

yogch commented Aug 18, 2015

Sometimes, I get 502 when calling bot.getUpdates() method.

Log:

2015-08-18 14:11:01,642 ERROR STDERR - Traceback (most recent call last):
2015-08-18 14:11:01,642 ERROR STDERR - File "../../python-telegram-bot/telegram/bot.py", line 621, in _requestUrl
2015-08-18 14:11:01,643 ERROR STDERR - ).read()
2015-08-18 14:11:01,643 ERROR STDERR - File "/usr/lib/python3.4/urllib/request.py", line 153, in urlopen
2015-08-18 14:11:01,643 ERROR STDERR - return opener.open(url, data, timeout)
2015-08-18 14:11:01,643 ERROR STDERR - File "/usr/lib/python3.4/urllib/request.py", line 461, in open
2015-08-18 14:11:01,644 ERROR STDERR - response = meth(req, response)
2015-08-18 14:11:01,644 ERROR STDERR - File "/usr/lib/python3.4/urllib/request.py", line 571, in http_response
2015-08-18 14:11:01,644 ERROR STDERR - 'http', request, response, code, msg, hdrs)
2015-08-18 14:11:01,644 ERROR STDERR - File "/usr/lib/python3.4/urllib/request.py", line 499, in error
2015-08-18 14:11:01,645 ERROR STDERR - return self._call_chain(_args)
2015-08-18 14:11:01,645 ERROR STDERR - File "/usr/lib/python3.4/urllib/request.py", line 433, in _call_chain
2015-08-18 14:11:01,645 ERROR STDERR - result = func(_args)
2015-08-18 14:11:01,645 ERROR STDERR - File "/usr/lib/python3.4/urllib/request.py", line 579, in http_error_default
2015-08-18 14:11:01,646 ERROR STDERR - raise HTTPError(req.full_url, code, msg, hdrs, fp)
2015-08-18 14:11:01,646 ERROR STDERR - urllib.error
2015-08-18 14:11:01,646 ERROR STDERR - .
2015-08-18 14:11:01,646 ERROR STDERR - HTTPError
2015-08-18 14:11:01,646 ERROR STDERR - :
2015-08-18 14:11:01,646 ERROR STDERR - HTTP Error 502: Bad Gateway
2015-08-18 14:11:01,647 ERROR STDERR -
2015-08-18 14:11:01,647 ERROR STDERR - During handling of the above exception, another exception occurred:
2015-08-18 14:11:01,647 ERROR STDERR - Traceback (most recent call last):
2015-08-18 14:11:01,647 ERROR STDERR - File "main.py", line 25, in handleUpdate
2015-08-18 14:11:01,647 ERROR STDERR - for update in bot.getUpdates(offset=lastUpdateID + 1, timeout=120):
2015-08-18 14:11:01,647 ERROR STDERR - File "../../python-telegram-bot/telegram/bot.py", line 79, in decorator
2015-08-18 14:11:01,647 ERROR STDERR - result = func(self, _args, *_kwargs)
2015-08-18 14:11:01,648 ERROR STDERR - File "../../python-telegram-bot/telegram/bot.py", line 120, in decorator
2015-08-18 14:11:01,648 ERROR STDERR - return func(self, _args, *_kwargs)
2015-08-18 14:11:01,648 ERROR STDERR - File "../../python-telegram-bot/telegram/bot.py", line 546, in getUpdates
2015-08-18 14:11:01,648 ERROR STDERR - json_data = self._requestUrl(url, 'POST', data=data)
2015-08-18 14:11:01,648 ERROR STDERR - File "../../python-telegram-bot/telegram/bot.py", line 623, in _requestUrl
2015-08-18 14:11:01,649 ERROR STDERR - raise TelegramError(str(e))
2015-08-18 14:11:01,649 ERROR STDERR - telegram.error
2015-08-18 14:11:01,649 ERROR STDERR - .
2015-08-18 14:11:01,649 ERROR STDERR - TelegramError
2015-08-18 14:11:01,649 ERROR STDERR - :
2015-08-18 14:11:01,649 ERROR STDERR - HTTP Error 502: Bad Gateway
2015-08-18 14:11:01,650 ERROR STDERR -
2015-08-18 14:11:01,650 ERROR STDERR - During handling of the above exception, another exception occurred:
2015-08-18 14:11:01,650 ERROR STDERR - Traceback (most recent call last):
2015-08-18 14:11:01,650 ERROR STDERR - File "main.py", line 90, in
2015-08-18 14:11:01,650 ERROR STDERR - lastUpdateID = handleUpdate(bot, lastUpdateID)
2015-08-18 14:11:01,650 ERROR STDERR - File "main.py", line 54, in handleUpdate
2015-08-18 14:11:01,650 ERROR STDERR - except urllib.HTTPError as httpErr:
2015-08-18 14:11:01,651 ERROR STDERR - AttributeError
2015-08-18 14:11:01,651 ERROR STDERR - :

@leandrotoledo
Copy link
Member

How exactly to reproduce? Are these errors common in what kind of messages? Would you handle these exceptions and print its messages.to_json()?

Thanks!

@JokerQyou
Copy link

A 502 error indicates that the gateway failed to pass the request to the backend servers, which is, as its first digit indicates, a server error. So actually what you can do is very limited, usually you would want to catch these exceptions and ignore them, or alert that the operation failed.

I've experienced 502 Bad Gateway that day before yesterday, when I was trying to send photo to Telegram server. The errors were gone by yesterday, and I did not change any code related to this. So I think it's the Telegram server's fault.

@yogch
Copy link
Author

yogch commented Aug 19, 2015

Thanks,

I don't know how to reproduce. For the moment I put exception handling (as I should) and it didn't happen again yet.

It was pretty random, I mean, I think I got it while I was blocking in the getUpdates() function, and waiting for text messages only. So I don't know what to say :\

I'll tell if it'll happen again.

@alfem
Copy link

alfem commented Oct 16, 2015

I got this error yesterday too. I wonder if it is some kind of abuse protection.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants