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.