最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python telegram bot - Configuring aiogram 3.16 bot to use the server's proxy - Stack Overflow

programmeradmin3浏览0评论

This aiogram bot I made runs perfectly on my PC, but when I went to run it on their server, it gives me this error

aiogram.exceptions.TelegramNetworkError: HTTP Client says - ClientConnectorDNSError: Cannot connect to host api.telegram:4
43 ssl:default [getaddrinfo failed]

Now, understanding that they use a proxy, I checked it with this first

import aiohttp
import asyncio

async def test_proxy():
    proxy_url = "http://172.16.2.11:8080"
    async with aiohttp.ClientSession(proxy=proxy_url) as session:
        async with session.get(";) as response:
            print(await response.text())

asyncio.run(test_proxy())

and this works (i.e., returns HTML code).

Now, the problem is how do I configure my bot to connect to api.telegram?

If you can give a small example of a bot configured with the above proxy and returns hello when "/start" is hit would be amazing.

发布评论

评论列表(0)

  1. 暂无评论