Forums

Connection error

Traceback (most recent call last): File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in wrap_create_connection return await self._loop.create_connection(args, kwargs) # type: ignore[return-value] # noqa File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('87.240.137.206', 443) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/KirillTarasov/BOT/Bot.py", line 269, in <module> asyncio.run(main()) File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/home/KirillTarasov/BOT/Bot.py", line 266, in main await bot.run_polling() File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/framework/bot/bot.py", line 81, in run_polling async for event in polling.listen(): File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/polling/bot_polling.py", line 57, in listen server = await self.get_server() File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/polling/bot_polling.py", line 51, in get_server self.group_id = (await self.api.request("groups.getById", {}))["response"][0]["id"] File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/api/api.py", line 72, in request response = await self.http_client.request_text( File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/http/aiohttp.py", line 73, in request_text response = await self.request_raw(url, method, data, kwargs) File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/http/aiohttp.py", line 50, in request_raw async with self.session.request(url=url, method=method, data=data, *kwargs) as response: File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 901, in _create_connection , proto = await self._create_direct_connection(req, traces, timeout) File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection raise last_exc File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host api.vk.com:443 ssl:default [Connect call failed ('87.240.137.206', 443)]

I created my own bot for the VKontakte social network, but it gives an error, although everything is fine in the Paycharm. Help please

If I try to launch the bot for the second time, I get this error:

Traceback (most recent call last): File "/home/KirillTarasov/.local/lib/python3.10/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(args, kwargs) # type: ignore[return-value] # noqa File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1064, in create_connection raise exceptions[0] File "/usr/local/lib/python3.10/asyncio/base_events.py", line 1049, in create_connection sock = await self._connect_sock( File "/usr/local/lib/python3.10/asyncio/base_events.py", line 960, in _connect_sock await self.sock_connect(sock, address) File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 500, in sock_connect return await fut File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 535, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('87.240.190.70', 443) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/KirillTarasov/Bot VK.py", line 269, in <module> asyncio.run(main()) File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/events/objects/init.py", line 1, in <module> File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/usr/local/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete return future.result() File "/home/KirillTarasov/Bot VK.py", line 266, in main await bot.run_polling() File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/framework/bot/bot.py", line 81, in run_polling async for event in polling.listen(): File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/polling/bot_polling.py", line 57, in listen server = await self.get_server() File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/polling/bot_polling.py", line 51, in get_server self.group_id = (await self.api.request("groups.getById", {}))["response"][0]["id"] Traceback (most recent call last): File "/home/KirillTarasov/Bot VK.py", line 6, in <module> from vkbottle import Bot File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle/init.py", line 1, in <module> from vkbottle_types import GroupTypes File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/init.py", line 1, in <module> from .events import GroupTypes, UserTypes File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/events/init.py", line 3, in <module> from .bot_events import * # noqa File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/events/bot_events.py", line 7, in <module> from .objects import BaseEventObject, group_event_objects File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/events/objects/init.py", line 1, in <module> from . import group_event_objects, user_event_objects File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/events/objects/group_event_objects.py", line 4, in <module> from vkbottle_types.objects import ( File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/objects.py", line 7, in <module> from vkbottle_types.codegen.objects import * File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/codegen/objects.py", line 7, in <module> class AccountAccountCounters(BaseModel): File "/home/KirillTarasov/.local/lib/python3.10/site-packages/vkbottle_types/base_model.py", line 6, in new return super().new(cls, args, resolve_forward_refs=False, **kwargs) File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.new File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.init File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis File "/usr/local/lib/python3.10/typing.py", line 1157, in subclasscheck return issubclass(cls, self.origin) TypeError: issubclass() arg 1 must be a class

Here is my bot code:

*It doesn't fit

The first error looks like you need to configure the library you're using to use the proxy. Check the documentation for the library to see how to do that. The details you need are here: https://help.pythonanywhere.com/pages/403ForbiddenError/.

The second error looks like some sort of issue with your pydantic configuration.

I'm just starting to learn programming so far. Can you describe in more detail how to solve these problems? Maybe I should send my code sometime here?

Unfortunately we can't give help at that level of detail; there are thousands of packages out there. But perhaps if you share the exact code you're using to make the HTTP request, we'll see something simple that you can change?

I can upload the code in the form of screenshots, since the code in text format does not want to be uploaded here. https://ibb.co/album/N9DyCn

Which specific part of the code is failing?