Skip to content

Bug: polling() not connecting to Telegram API (requests timeout) #2187

@shorecodeorg

Description

@shorecodeorg

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using?

4.16.1

  1. What OS are you using?

Linux Mint

  1. What version of python are you using?

3.10.12

Issue: When I try to use polling() I get a timeout error from requests library.

Steps I took to isolate the issue:

  1. Test outside Python
    I tested the API endpoint using a curl tool and I was successful in getting responses from the getme and getupdates endpoint when using the same URL that pyTelegramBotAPI uses.

  2. Test requests
    I tested the Python requests library with a different URL and received a quick 200 response.

  3. Test requests with bot URL
    I tested the Python requests library with the same URL that pyTelegramBotAPI uses and there was no response. Implemented a 10 second timeout throws the timeout error as expected.

  4. Test requests with Telegram API
    I tested the Python request library using the get method to connect to 'https://api.telegram.org/', again no response.

It would appear that the requests library cannot connect to the Telegram bot API.

When enabling debug I get the following:

2024-02-26 10:16:17,005 (apihelper.py:87 MainThread) DEBUG - TeleBot: "Request: method=get url=https://api.telegram.org/botXXXXXXX:{TOKEN}/getMe params=None files=None"

XXXXXXX being the first section before the colon of my api token, edited for privacy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions