I intend to set up my Telegram bot with webhook. I have configured everything according to instructions I have found from valid sources.
However, Bot is not receiving webhook updates and I get below error when I send “getWebhookInfo” request to Telegram API.
{"ok":true,"result":{"url":"https://161.35.18.8/1058222550:AAFPb5oCPKfKLkJbMlvzg1rKEDw7-qx30Ww","has_custom_certificate":true,"pending_update_count":4,"last_error_date":1585773597,"last_error_message":"Connection timed out","max_connections":40}}
Here is the configuration I have done for the droplet on Digitalocean.
Created a self-signed key and certificate pair with OpenSSL and put them in /etc/ssl/private/ and /etc/ssl/certs/
The firewall was adjusted and below is the FW status:
To Action From
-- ------ ----
Nginx HTTP ALLOW Anywhere
22/tcp ALLOW Anywhere
OpenSSH ALLOW Anywhere
Nginx HTTP (v6) ALLOW Anywhere (v6)
22/tcp (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
default server block file in the /etc/nginx/sites-available directory was modified as follows:server {
listen 443 ssl;
server_name SERVER_IP_ADDRESS;
ssl_certificate bot.pem;
ssl_certificate_key private.key;
location /TOKEN1 {
proxy_pass http://127.0.0.1:5000/TOKEN1/;
}
location /TOKEN2 {
proxy_pass http://127.0.0.1:5001/TOKEN2/;
}
}
sudo nginx -t && sudo systemctl restart nginx and getting the below output:nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
In my application file which is running on the server, the python script is as follows to get updates from Telegram :
updater.start_webhook(listen='127.0.0.1', port=5000, url_path='TokenID')
updater.bot.set_webhook(webhook_url='https://<DropletID>/TokenId',
certificate=open('bot.pem', 'rb'))
Am I missing something somewhere? Any idea what could be the cause of the problem? Any help is very much appreciated. Thanks.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I think you need to open the HTTPS port (443) to be available to listen to it.
try with: sudo ufw allow https
I have a similar problem, I keep getting connection refused errors, but only when Telegram servers are trying to access my webserver. If I do a POST from my browser, it works fine.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.