V
V
Vladislav2020-12-05 20:17:49
Java
Vladislav, 2020-12-05 20:17:49

How to make the bot not turn off after 90 seconds?

Wrote a bot on Maven. Using telegrambots. First posted on hiroku. The bot works for the first 90 seconds, and then writes:
2020-12-05T17:11:09.224270+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 90 seconds of launch
2020-12-05T17:11:09.239511+00:00 heroku[web.1]: Stopping process with SIGKILL
I understand the bot needs to contact the hiroku port, but I don't know how.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2020-12-05
Hasanly @azerphoenix

Hello!
The answer to your question is https://stackoverflow.com/questions/51241023/herok...

public class Bot extends TelegramLongPollingBot {
    private static final String TOKEN = System.getenv("TOKEN");
    private static final String BOT_USERNAME = System.getenv("BOT_USERNAME");
    private static final String PORT = System.getenv("PORT");

    public void onUpdateReceived(Update update) {

    }

    public String getBotUsername() {
        return BOT_USERNAME;
    }

    public String getBotToken() {
        return TOKEN;
    }

    public static void main(String[] args) {
        ApiContextInitializer.init();
        TelegramBotsApi api = new TelegramBotsApi();
        try {
            api.registerBot(new Bot());
        } catch (TelegramApiRequestException e) {
            e.printStackTrace();
        }

        try (ServerSocket serverSocket = new ServerSocket(Integer.valueOf(PORT))) {
            while (true) {
                Socket clientSocket = serverSocket.accept();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question