[英]python-telegram-bot.I already PORT 8443 but Error while bootstrap set webhook: Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443
當我創建這篇文章時,我只是在 stackoverflow 上找到了沒有任何回復的帖子...... TelegramBot。 heroku 網絡服務器上的“Webhook 只能在端口 80、88、443 或 8443 上設置”錯誤
我的測試代碼在這里:
from configparser import ConfigParser
import logging
import os
import telegram
from flask import Flask, request
from telegram.ext import Updater, Dispatcher, MessageHandler, Filters, CommandHandler
env = ConfigParser()
env.read('config.ini')
TOKEN = env['TELEGRAM']['ACCESS_TOKEN']
PORT = int(os.environ.get('PORT', '8443'))
updater = Updater(token=TOKEN)
#
#body part ( that's not important to show)
#
updater.start_webhook(listen="0.0.0.0",
port=PORT,
url_path=TOKEN)
updater.bot.set_webhook("https://tgbot00.herokuapp.com/" + TOKEN)
updater.idle()
但是服務員告訴我...
here2021-03-19T14:48:06.712894+00:00 app[web.1]: Error while bootstrap set webhook: Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443
2021-03-19T14:48:06.713033+00:00 app[web.1]: Failed bootstrap phase after 0 retries (Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443)
我已經為此苦苦掙扎了大約一周,幾乎成功了,但不知何故,在谷歌上找到的信息太少了
我需要在我的遠程 Linux 系統上設置一些關於 PORT 的東西嗎?
有人可以幫忙嗎?
多謝...!
更新---------------------------------------- https://github.com/python -telegram-bot/python-telegram-bot/wiki/Webhooks#heroku
我認為這與 SSL 問題無關
Heroku
On Heroku using webhook can be beneficial on the free-plan because it will
automatically manage the downtime required. The reverse proxy is set up for you and an environment
is created. From this environment you will have to extract the port the bot is supposed to listen on.
Heroku manages the SSL on the proxy side, so you don't have provide the certificate yourself.
文檔更新: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks#heroku
import os
TOKEN = "TOKEN"
PORT = int(os.environ.get('PORT', '8443'))
updater = Updater(TOKEN)
# add handlers
updater.start_webhook(listen="0.0.0.0",
port=PORT,
url_path=TOKEN,
webhook_url="https://<appname>.herokuapp.com/" + TOKEN)
updater.idle()
不使用set_webhook
,在start_webhook
中使用webhook_url
參數
2021-03-19T18:12:15.168205+00:00 heroku[web.1]: State changed from crashed to starting
2021-03-19T18:12:20.004562+00:00 heroku[web.1]: Starting process with command `python3 main.py`
2021-03-19T18:12:24.283471+00:00 app[web.1]: Error while bootstrap set webhook: Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443
2021-03-19T18:12:24.283508+00:00 app[web.1]: Failed bootstrap phase after 0 retries (Bad webhook: webhook can be set up only on ports 80, 88, 443 or 8443)
2021-03-19T18:12:24.286525+00:00 app[web.1]: unhandled exception in Bot:1747558409:updater
2021-03-19T18:12:24.286526+00:00 app[web.1]: Traceback (most recent call last):
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.