Skip to content

[BUG] Proxy conflicts with CommandHandler. #4526

@downdawn

Description

@downdawn

Steps to Reproduce

from loguru import logger
from telegram import Update
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes

bot_token = "xxxx"
proxy = "http://127.0.0.1:1080"


async def get_config(update: Update, context: ContextTypes.DEFAULT_TYPE):
    try:
        chat_id = update.effective_chat.id
        print(chat_id)
    except Exception as e:
        logger.exception(e)


if __name__ == '__main__':
    application = ApplicationBuilder().token(bot_token).proxy(proxy=proxy).build()

    application.add_handler(CommandHandler('get_config', get_config))

    application.run_polling(allowed_updates=Update.ALL_TYPES)

Expected behaviour

Input /get_config on the Telegram bot, and the console will output the chat_id.

Actual behaviour

With this proxy setup, the command handler is not working; the get_config method is not being entered, and there is no output for chat_id.

Operating System

windows10

Version of Python, python-telegram-bot & dependencies

python3.10
python-telegram-bot>=21.6

Relevant log output

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions