我打算用webhook设置我的Telegram机器人。我已经根据从有效来源中找到的说明配置了所有内容。
但是,Bot没有收到webhook更新,并且当我向Telegram API发送“ getWebhookInfo”请求时出现错误消息。
{"ok":true,"result":{"url":"https://161.35.18.8/1058222550:XXXXXXXXXXXXXXXrKEDw7-qx30Ww","has_custom_certificate":true,"pending_update_count":4,"last_error_date":1585773597,"last_error_message":"Connection timed out","max_connections":40}}
这是我为Digitalocean上的小滴所做的配置。
使用OpenSSL创建了自签名密钥和证书对,并将它们放在/ etc / ssl / private /和/ etc / ssl / certs /
防火墙已调整,以下是固件状态:
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
服务器块文件中给出的说明配置Nginx nginx / sites-available目录修改如下: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
并获取以下输出来重新启动Web服务器:nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
在服务器上运行的应用程序文件中,python脚本如下所示,以从Telegram获取更新:
updater.start_webhook(listen='127.0.0.1', port=5000, url_path='TokenID')
updater.bot.set_webhook(webhook_url='https://<DropletIP>/TokenId',
certificate=open('bot.pem', 'rb'))
我在某处缺少什么吗?任何想法可能是问题的原因吗?很感谢任何形式的帮助。谢谢。