rubenlagus / TelegramBots

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

Proxy solutions #154

Closed denred0 closed 7 years ago

denred0 commented 8 years ago

Hi! I use your cool library, but i dont understand how correctly use it with proxy. I read all issues about it but dont find solution.

I use TelegramLongPollingBot and folowing code: TelegramBotsApi telegramBotsApi = new TelegramBotsApi(); TelegramLongPollingBot bot = new MainBot(); bot.getOptions().setProxyHost("10.40.40.19"); bot.getOptions().setProxyPort(3128);

    try {
        telegramBotsApi.registerBot(bot);
    } catch (TelegramApiException e) {
        e.printStackTrace();
    }

I get error

org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error deserializing setWebhook method response at org.telegram.telegrambots.TelegramBotsApi.setWebhook(TelegramBotsApi.java:164) at org.telegram.telegrambots.TelegramBotsApi.setWebhook(TelegramBotsApi.java:181) at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:98) at contactBot.MainBot.main(MainBot.java:57) Caused by: org.json.JSONException: A JSONObject text must begin with '{' at 1 [character 2 line 1]

What do I wrong? Thank you for help.

flicus commented 8 years ago

You doing all right. Most probably its something with your proxy server, for example it is SOCKS proxy. This library supports only HTTP proxy.

denred0 commented 8 years ago

@flicus i have https proxy server. Is It mean no way to use this library for https proxy server?

rubenlagus commented 7 years ago

The new version allows to set custom RequestConfig, that should give a better way of setting up proxis (hope)

rubenlagus commented 7 years ago

Was this solved with las version @DenisWpk ?