Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running #288

Open
StormLord07 opened this issue Nov 12, 2023 · 0 comments

Comments

@StormLord07
Copy link

There was some problem with longpoll which caused segfault or the thread to just be locked, not receiving/posting any requests like in this Issue I tried to do the most sensible thing and just wrap it in the try-catch

        try {
            std::cout << "Bot username: @" << bot->getApi().getMe()->username << std::endl;
            TgBot::TgLongPoll longPoll(*bot);

            int retryCount = 0;
            while (true) {
                try {
                    longPoll.start();
                    retryCount = 0;  // Reset retry count after successful start
                }
                catch (const boost::system::system_error& e) {
                    if (retryCount < MAX_RETRIES) {
                        std::cerr << "Boost System Error: " << e.what() << ". Retrying in " << RETRY_WAIT_TIME << " seconds." << std::endl;
                        std::this_thread::sleep_for(std::chrono::seconds(RETRY_WAIT_TIME));
                        retryCount++;
                    } else {
                        std::cerr << "Max retries reached. Exiting." << std::endl;
                        throw;  // Re-throw the exception to the outer catch block
                    }
                }
            }
        }
        catch (const TgBot::TgException &e) {
            std::cerr << "Telegram Error: " << e.what() << std::endl;
        }
        catch (const std::exception& e) {
            std::cerr << "Standard Exception: " << e.what() << std::endl;
        }
        catch (...) {
            std::cerr << "Unknown exception caught." << std::endl;
        }
        ```
        
        which now causes `Telegram Error: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running`
        or just "Standart Exception" with e.what being something unreadable, maybe I'm doing something wrong, but the problem seems to be with how longpoll works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant