rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.78k stars 1.22k forks source link

Error removing old webhook #481

Closed btow closed 6 years ago

btow commented 6 years ago

This is method main() code:

    public static void main(String[] args) {
         // Set up Http proxy
        DefaultBotOptions botOptions = ApiContext.getInstance(DefaultBotOptions.class);

        CredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(
            new AuthScope(PROXY_HOST, PROXY_PORT),
            new UsernamePasswordCredentials(PROXY_USER, PROXY_PASSWORD));

        HttpHost httpHost = new HttpHost(PROXY_HOST, PROXY_PORT);

        RequestConfig requestConfig = RequestConfig.custom().setProxy(httpHost).setAuthenticationEnabled(true).build();
        botOptions.setRequestConfig(requestConfig);
        botOptions.setCredentialsProvider(credsProvider);
        botOptions.setHttpProxy(httpHost);

        ApiContextInitializer.init();
        TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
        try {
            telegramBotsApi.registerBot(new Bot(botOptions));
        } catch (TelegramApiRequestException e) {
            e.printStackTrace();
        }
    }

This is logcat:

org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error removing old webhook
at  org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:32)
at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:120)
at Bot.main(Bot.java:61)

Getting a new token in BotFather does not help. How to get rid of this error?

btow commented 6 years ago

The problem is solved through the organization of VPN connection.