English 中文(简体)
Cannotlink toshop api.telegram.org:443 ssl:default
原标题:Cannot connect to host api.telegram.org:443 ssl:default

I am writing a telegram bot on the aiogram framework. Everything was good when I run it, but today I am getting error,Cannot connect to host api.telegram.org:443 ssl:default I do not know what s problem.
I am using Ubuntu 20.04.2 LTS
Here is the full error

Traceback (most recent call last):
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/connector.py", line 1154, in _create_direct_connection
    hosts = await asyncio.shield(host_resolved)
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/connector.py", line 880, in _resolve_host
    addrs = await self._resolver.resolve(host, port, family=self._family)
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/resolver.py", line 33, in resolve
    infos = await self._loop.getaddrinfo(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/bot/api.py", line 139, in make_request
    async with session.post(url, data=req, **kwargs) as response:
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Temporary failure in name resolution]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "app.py", line 18, in <module>
    executor.start_polling(dp, on_startup=on_startup)
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 45, in start_polling
    executor.start_polling(
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 320, in start_polling
    loop.run_until_complete(self._startup_polling())
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 372, in _startup_polling
    await self._welcome()
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/utils/executor.py", line 361, in _welcome
    user = await self.dispatcher.bot.me
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/bot/bot.py", line 30, in me
    setattr(self,  _me , await self.get_me())
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/bot/bot.py", line 228, in get_me
    result = await self.request(api.Methods.GET_ME, payload)
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/bot/base.py", line 231, in request
    return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
  File "/home/mirodil/.local/share/virtualenvs/allinone-kbyzCwMv/lib/python3.8/site-packages/aiogram/bot/api.py", line 142, in make_request
    raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientConnectorError: Cannot connect to host api.telegram.org:443 ssl:default [Temporary failure in name resolution]

问题回答

我假定,你是在斯堪的阿尼处驾驶你的斯堪达克的机器人。 如果情况确实如此,则确保把代理机构并入机器人:

bot = Bot(token= YOUR API TOKEN GOES HERE , proxy= http://proxy.server:3128 )

如果已经设立,你仍然从Adhur Any处获得与TLS-in-TLS有关的错误:

  1. Tap consoles on the Menu option.
  2. Close the console in which your script is running.
  3. Run the script again.

页: 1

但是,考虑到以下错误:<代码>socket.gaierror: [Errno -3] 代表第/etc/hosts文档,看看是否存在任何错误配置。

如果两者都没有奏效,则直接尝试投票,看看问题是否仍然存在。

In general, setting up webhooks are much better than long polling. It takes a bit of a setup, requires an API and a reverse proxy like ngrok, but once it is up and running, it is a very hassle free and elegant solution compared to long polling. I created a POC for telegram webhooks, which might be of help if you re looking to switch from long polling to webhooks.

www.un.org/Depts/ 概念证明

https://github.com/thevickypedia/telegram-webhook

<Java :https://github.com/thevickypedia/telegram-webhook-children” rel=“nofollow noreferer”>https://github.com/thevickypedia/telegram-webhook-children





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签