【问题标题】:python-telegram-bot webhook doesn't work?python-telegram-bot webhook 不起作用?
【发布时间】:2020-09-22 06:58:27
【问题描述】:

我在启动我的机器人时记录该日志

2020-06-03 17:10:21,867 - telegram.ext.updater - ERROR - unhandled exception in Bot:1023524274:updater
Traceback (most recent call last):
  File "/home/maksym/project/univesal_queue_bot/lib/python3.7/site-packages/telegram/ext/updater.py", line 216, in _thread_wrapper
    target(*args, **kwargs)
  File "/home/maksym/project/univesal_queue_bot/lib/python3.7/site-packages/telegram/ext/updater.py", line 452, in _start_webhook
    self.httpd.serve_forever()
  File "/home/maksym/project/univesal_queue_bot/lib/python3.7/site-packages/telegram/utils/webhookhandler.py", line 52, in serve_forever
    self.http_server.listen(self.port, address=self.listen)
  File "/home/maksym/project/univesal_queue_bot/lib/python3.7/site-packages/tornado/tcpserver.py", line 151, in listen
    sockets = bind_sockets(port, address=address)
  File "/home/maksym/project/univesal_queue_bot/lib/python3.7/site-packages/tornado/netutil.py", line 174, in bind_sockets
    sock.bind(sockaddr)
PermissionError: [Errno 13] Permission denied
2020-06-03 17:10:22,893 - telegram.ext.dispatcher - CRITICAL - stopping due to exception in another thread

我用:

python 3.7 蟒蛇电报机器人12.7 16+ 自签名证书

【问题讨论】:

标签: python telegram python-telegram-bot


【解决方案1】:

python-telegram-bot 默认在端口 80 (see source code) 启动 HTTP webhook 服务器。

在 Linux 中,只有提升权限的用户才能运行绑定到端口号低于 1024 的套接字的进程。使用sudo python yourbot.py 以root 身份运行您的应用程序(根据您的设置可能是个坏主意)或允许Python to bind to privileged ports

否则,可能有另一个进程已经在使用该端口。

【讨论】:

    猜你喜欢
    • 2016-04-10
    • 2018-03-12
    • 1970-01-01
    • 2019-08-07
    • 2017-01-11
    • 1970-01-01
    • 2016-03-12
    • 2016-07-15
    • 1970-01-01
    相关资源
    最近更新 更多