Forums

Telegram Bot suddenly died O_O

Hi there! I`ve been hosting my telegram bot on pythonanywhere for a week and it worked perfectly. But unexpectedly something went wrong... Please help me to solve the problem. Here is my code corresponding to webhook (I use pyTelegramBotAPI) :

import telebot
bot = telebot.TeleBot(TOKEN, threaded=False)
app = Flask(__name__)

@app.route('/')
def start_app():
   return '!'

bot.remove_webhook()
bot.set_webhook("https://impecableme.pythonanywhere.com/{}".format(TOKEN))

@app.route('/{}'.format(config.TOKEN), methods=['POST'])
def getMessage():
   bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
   return "!", 200

The error log is following:

       Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 572, in urlopen
    self._prepare_proxy(conn)
  File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 780, in _prepare_proxy
    conn.connect()
  File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connection.py", line 267, in connect
    self._tunnel()
  File "/usr/lib/python3.5/http/client.py", line 827, in _tunnel
    (version, code, message) = response._read_status()
  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 403, in send
    timeout=timeout
  File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/connectionpool.py", line 623, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.5/dist-packages/requests/packages/urllib3/util/retry.py", line 281, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot393985494:AAFSHfaehl5
LXDEaaYpA77pzuKpWMV61zJk/setWebhook?url= (Caused by ProxyError('Cannot connect to proxy.', timeout('timed out',)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/impecableMe/mysite/flask_app.py", line 23, in <module>
    bot.remove_webhook()
  File "/home/impecableMe/.local/lib/python3.5/site-packages/telebot/__init__.py", line 118, in remove_webhook
    return self.set_webhook()  # No params resets webhook
  File "/home/impecableMe/.local/lib/python3.5/site-packages/telebot/__init__.py", line 104, in set_webhook
    return apihelper.set_webhook(self.token, url, certificate, max_connections, allowed_updates)
  File "/home/impecableMe/.local/lib/python3.5/site-packages/telebot/apihelper.py", line 147, in set_webhook
    return _make_request(token, method_url, params=payload, files=files)
  File "/home/impecableMe/.local/lib/python3.5/site-packages/telebot/apihelper.py", line 51, in _make_request
    timeout=(connect_timeout, read_timeout), proxies=proxy)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 465, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot393985494:AAFSHfaehl5LXDEaaYpA77pzuKpWMV6
1zJk/setWebhook?url= (Caused by ProxyError('Cannot connect to proxy.', timeout('timed out',)))

What is more, now there is generally the same thing with long polling and I can not acess not exact this but any bot. Updating, removing and building a new webapp didn`t help.

hi, can you show me a error log?

i'm using telepot, python3.5 same as you..

Hi! I updated the post. As far as I know, using telepot you have to set proxy settings by yourself?

Hi there,

Sorry about that- we had some problems with the proxy server for our free users (which made it hard to connect to whitelisted external websites). We have fixed that now- please let us know if you are still experiencing any problems!

We will also definitely look into implementing better monitoring/alerting to help us detect such problems earlier.

Now everything is awesome :) Thank you so much for fixing the problem!!

It happened again now? I'm experiencing same problem with my bot

Is your bot using webhooks? Or is it something you're running in a console?