Answer the question
In order to leave comments, you need to log in
Why don't WebHooks work on Amazon Windows Server 2016?
Good afternoon, I got myself a VPS on Amazon, on Windows Server 2016.
I got two ip addresses there, external (we will call it 1.1.1.1) and internal (2.2.2.2)
Then I made a self-signed certificate on ubunt for ip 1.1.1.1.
Then I performed all the operations for setting up the "body" of the bot according to the instructions of the respected Groosha ( https://groosha.gitbooks.io/telegram-bot-lessons/c...
When the bot is launched, the following happens:
[12/Dec/2017:09:22:37] ENGINE Listening for SIGTERM.
[12/Dec/2017:09:22:37] ENGINE Bus STARTING
[12/Dec/2017:09:22:37] ENGINE Set handler for console events.
[12/Dec/2017:09:22:37] ENGINE Started monitor thread 'Autoreloader'.
[12/Dec/2017:09:22:37] ENGINE Serving on https://0.0.0.0
[12/Dec/2017:09:22:37] ENGINE Bus STARTED
#!/usr/bin/python3.4
# -*- coding: utf-8 -*-
import telebot
import cherrypy
import config
WEBHOOK_HOST = ‘1.1.1.1’ #внешний ip выданный Amazon
WEBHOOK_PORT = 443
WEBHOOK_LISTEN = '0.0.0.0'
WEBHOOK_SSL_CERT = './webhook_cert.pem'
WEBHOOK_SSL_PRIV = './webhook_pkey.pem'
WEBHOOK_URL_BASE = "https://%s:%s" % (WEBHOOK_HOST, WEBHOOK_PORT)
WEBHOOK_URL_PATH = "/%s/" % (config.token)
bot = telebot.TeleBot(config.token)
class WebhookServer(object):
@cherrypy.expose
def index(self):
if 'content-length' in cherrypy.request.headers and \
'content-type' in cherrypy.request.headers and \
cherrypy.request.headers['content-type'] == 'application/json':
length = int(cherrypy.request.headers['content-length'])
json_string = cherrypy.request.body.read(length).decode("utf-8")
update = telebot.types.Update.de_json(json_string)
# Эта функция обеспечивает проверку входящего сообщения
bot.process_new_updates([update])
return ''
else:
raise cherrypy.HTTPError(403)
@bot.message_handler(func=lambda message: True, content_types=['text'])
def echo_message(message):
bot.reply_to(message, message.text)
bot.remove_webhook()
bot.set_webhook(url=WEBHOOK_URL_BASE + WEBHOOK_URL_PATH,
certificate=open(WEBHOOK_SSL_CERT, 'r'))
cherrypy.config.update({
'server.socket_host': WEBHOOK_LISTEN,
'server.socket_port': WEBHOOK_PORT,
'server.ssl_module': 'builtin',
'server.ssl_certificate': WEBHOOK_SSL_CERT,
'server.ssl_private_key': WEBHOOK_SSL_PRIV
})
cherrypy.quickstart(WebhookServer(), WEBHOOK_URL_PATH, {'/': {}})
Answer the question
In order to leave comments, you need to log in
Hello, faced the same problem. Is there any progress in solving this problem?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question