gpt4 book ai didi

python-telegram-bot.I 已经是 8443 端口,但是在引导设置 webhook : Bad webhook: webhook can be set up only on ports 80, 88、443 或 8443 时出错

转载 作者:行者123 更新时间:2023-12-04 14:08:04 61 4
gpt4 key购买 nike

当我创建这篇文章时,我只是在stackoverflow上找到了没有任何回复的帖子......
TelegramBot. "Webhook can be set up only on ports 80, 88, 443 or 8443" error on heroku webserver
我的测试代码在这里:

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 , 使用 webhook_url参数在 start_webhook

关于python-telegram-bot.I 已经是 8443 端口,但是在引导设置 webhook : Bad webhook: webhook can be set up only on ports 80, 88、443 或 8443 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66711302/

61 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com