Reputation: 1245
I developed a Telegram bot with the python-telegram-bot
library and now i want to deploy it in my server, so i setup a webhook(following the Official Wiki) but when i try to communicate with my bot i don't get any reply.
This is the source of the bot:
def main():
PRIVTOKEN = "1134xxxx"
updater = Updater(PRIVTOKEN)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
# ...
updater.start_webhook(listen='127.0.0.1',
port=8843,
url_path=PRIVTOKEN)
updater.bot.set_webhook(webhook_url='https://example.com/' + PRIVTOKEN,
certificate=open("cert.pem", "rb"))
print("bot started")
updater.idle()
the nginx config file:
server {
listen 443 ssl;
server_name example.com;
location /1134xxxx {
proxy_pass http://127.0.0.1:8443;
}
}
The netstat status:
sudo netstat -an | grep 8843
tcp 0 127.0.0.1:8843 0.0.0.0:* LISTEN
No other errors where logged either by the bot(i've enabled the error logs) or by nginx(access/error.log)
I’ve also added a custom rule for 8843 port in the firewall.
Upvotes: 5
Views: 6399
Reputation: 970
Telegram supports only https
requests. note this.
my nginx config:
server {
listen 80;
listen 443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
location / {
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://localhost:5005/;
}
}
Upvotes: 2