Forums

Как изменить прокси

Привет, столкнулся с проблемой при запуске телеграм бота при запуске бота пишет ошибку ClientConnectorError: Cannot connect to host api.telegram.org:443 s sl:default [Network is unreachable] Как я понял это ошибка из-за прокси, как можно его изменить

From a free account, you need to connect through our proxy. Check the documentation for the library that you're using to find out how to do that and the details you need are here: https://help.pythonanywhere.com/pages/403ForbiddenError/

А как его установить

Hi Davidtelegrambot, did you have a read of the page glenn linked above? Looking at your code you probably won't need to install anything. You'll just need to tell your bot that you're using a proxy. All PythonAnywhere free accounts use the same proxy for security reasons (see above link).

https://docs.aiogram.dev/en/latest/examples/proxy_and_emojize.html

Я читал ту страницу, в коде я сообщил чтобы он подключался к прокси, но ошибка осталась, возможно я не так дописал код, так как раньше мне не приходилось устанавливать на прокси сервера бота

You only need to use the proxy when your connecting out of PythonAnywhere from a free account.

У меня бесплатная учётная запись

Yes, so you need to connect though the proxy

А где этот прокси взять, я пытался разные прокси написать, но никакой не работает, выше скидывали ссылку на прокси, но не получается

The proxy details are in the page I linked to above.

Там написано про прокси, но какое вводить не написано, есть белый список сайтов, api.telegram.org входит в белый список, но у него нет прокси сервера, какое прокси вводить

The proxy details are in the help page. Can you show us the code that isn't working?

Вот код

from aiogram import executor, types
from aiogram.dispatcher import FSMContext
from loader import dp, bot, admin_id
from handlers import dp
from keybord_s.ohter import ikb_close

#отмена любого состаяния#
@dp.callback_query_handler(text='cancellation_state', state='*')
async def cancellation_state(call: types.CallbackQuery, state: FSMContext):
    await state.finish()
    await call.answer('Отмена❌')
    await call.message.delete()

#закрыть#
@dp.callback_query_handler(text='close_text')
async def cancellation_state(call: types.Message):
    await call.message.delete()

@dp.message_handler()
async def empty_command(message: types.Message):
    await message.delete()
    await message.answer('Такой команды нет

[edit by admin: formatting]

Could you show us the specific code where you configure the library that you're using to use a proxy rather than connecting directly to Telegram?

I see that earlier you asked for the proxy details; if you run

echo $http_proxy

...in.a Bash console, you'll get the hostname and the port.

Этот код используется для запуска бота, именно здесь прописывал подключение к прокси, если запускать этот код через cmd то бот запускается, так же пробовал запустить на сервере простой код, он запустился и работает, почему при запуске этого кода просит подключения к прокси

Could you try in English? Machine translation that I'm getting looks weird.

This code is used to launch the bot, this is where the proxy connection is specified, if you run this code via cmd to make the bot work, a simple code is also implemented on the server, it starts and works, why when using this code, you need to connect to a proxy

Free accounts on PythonAnywhere do not have direct Internet access. All access to external sites, including Telegram's API, need to make requests via a proxy. In your code, the decorators that define your query handlers operate by making a request to Telegram's API to register them. Because those API requests need to go via the proxy, you will need code in your site to tell the library that you are using to use the proxy. That last bit of code is the code that we need to see in order to help you.