rubenlagus / TelegramBots

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

How to set it up to connect using SOCKS5 proxy? #429

Open bvn13 opened 6 years ago

bvn13 commented 6 years ago

Is there any way to do that?

zugzug90 commented 6 years ago

@bvn13 Maybe we can customize something in https://github.com/rubenlagus/TelegramBots/blob/master/telegrambots/src/main/java/org/telegram/telegrambots/bots/DefaultBotOptions.java? It uses org.apache.http.client.config.RequestConfig in its guts.. that's the starting point, I guess, we can dig into. But not sure about SOCKS5.. maybe just HTTP(S) can be applied somehow.

/**
 * @implSpec Default implementation assumes no proxy is needed and sets a 75secs timoute
 * @param requestConfig Request config to be used in all Http requests
 */
public void setRequestConfig(RequestConfig requestConfig) {
    this.requestConfig = requestConfig;
}
ospavel commented 6 years ago

Hello! Thank you for Socks5 option in v.3.6.1! Is there ability to change socks5/proxy on the fly without recreating bot? For example, if working bot catches "Connection timed out" then just set new socks5/proxy (or remove it).

rubenlagus commented 6 years ago

@ospavel There is no support for socks5 yet, just for proxies. But not, at the moment, there is no way to change proxy without recreating the bot.

carlopantaleo commented 6 years ago

@ospavel @rubenlagus There's a workaround to set a SOCKS5 proxy, see here. It works, as I'm currently using it. However, in this way I think it is set at JVM level, so all requests (except those to localhost) are proxied.

AlexByte commented 6 years ago

@rubenlagus What about this? https://stackoverflow.com/questions/22937983/how-to-use-socks-5-proxy-with-apache-http-client-4

rubenlagus commented 5 years ago

@bvn13 This should be solved already, can be closed?

bvn13 commented 5 years ago

@rubenlagus I'll check it

bvn13 commented 5 years ago

@rubenlagus

I have tried to use 4.0.0 and 4.0.1 versions and didn't see any way to set up authentication for proxy.

Is this ability broken?