Aas*_*rma 2 python pythonanywhere telegram telegram-bot telepot
当我在 pythonanywhere 上部署我的机器人时,我无法向我的机器人发送消息。由于 telegram 不再支持通配符证书,如博客文章的官方 pythonanywhere 博客链接中所述,出现无法连接到服务器的错误。如果有人知道此问题的解决方案,请帮助我
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bottokenvalue/sendMessage (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f094debf050>: Failed to establish a new connection: [Errno 101] Network is unreachable'))
2020-01-17 21:58:04,377: Retrying (Retry(total=2, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f094da4c610>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /bottoken/sendMessage
2020-01-17 21:58:05,377: Retrying (Retry(total=1, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f094da4c4d0>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /bottokenbot/sendMessage
2020-01-17 21:58:06,377: Retrying (Retry(total=0, connect=None, read=None, redirect=0, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f094da4c810>: Failed to establish a new connection: [Errno 101] Network is unreachable')':
Run Code Online (Sandbox Code Playgroud)
更新
You can actually deploy to heroku, even with the free account, which appears to use wildcard certificates for a domain like your_app.herokuapp.com. This is using the library python-telegram-bot in a webhook configuration, as documented here.
I'm pretty certain heroku's certs are wildcard, so I'm not sure if Telegram have changed their system to allow wildcard certs. Their official documentation still suggests that wildcard certs are not allowed.
Original answer...
This sudden* lack of support for wildcard certs should only affect bots which are built with webhook support (and hosted on a domain with wildcard certs).
There are probably a few options to get round this:
Remove webhook support from your bot. This is probably the least preferable unless it's a low traffic bot / for personal use, and you didn't implement webhook support for a reason. Without webhook support your bot connects to telegrams API as a client, rather than acting as a server which telegram's system connects TO. This connection method is called "Polling".
Shift to a paid python anywhere account, which supports custom domains. With a custom domain you could then configure this with a non-wildcard cert. You can obtain a free certificate from Let's Encrypt.
You could of course take this opportunity to move to another host, but be careful as many similar hosts will only support wildcard certs for their free accounts: anything that gives you a public URL of youraccount.provider.tld
EDIT
(*) I inferreded from this question that the restriction on wildcard certs had suddenly/recently been introduced, however this goes as far back as March 2017, according to this answer. See the official docs for other restrictions on the SSL configuration.
| 归档时间: |
|
| 查看次数: |
768 次 |
| 最近记录: |