Closed Thus0 closed 10 years ago
Check out this piece of code taken from the Telegram app: https://github.com/ex3ndr/telegram/blob/499eb24891371f57a801a08cd2385ab30299113a/app/src/main/java/org/telegram/android/core/background/sync/BackgroundSync.java#L139
try {
TLConfig config = application.getApi().doRpcCallNonAuth(new TLRequestHelpGetConfig());
application.getApiStorage().updateSettings(config);
application.getTechKernel().getSystemConfig().onConfig(config);
application.getApi().resetConnectionInfo();
synced = true;
} catch (TimeoutException e) {
int[] knownDcs = application.getApiStorage().getKnownDc();
for (int i = 0; i < knownDcs.length; i++) {
try {
TLConfig config = application.getApi().doRpcCallNonAuth(new TLRequestHelpGetConfig(), knownDcs[i]);
application.getApiStorage().updateSettings(config);
application.getTechKernel().getSystemConfig().onConfig(config);
application.getApi().resetConnectionInfo();
synced = true;
break;
} catch (TimeoutException e1) {
}
}
}
Apparently you need to catch the timeout exception and provide your own datacenter addresses, or something like that.
I've tested the bot on linux/gentoo (java 1.6.0_45) and perhaps it's a duplicate bug of this one : https://github.com/ex3ndr/telegram-api/issues/9#issuecomment-37809473 and it's related to the jvm ?
It works on Windows with jvm 1.6 (no timeout) with production server :)
Check out the solution everyone who came here from Google: https://github.com/ex3ndr/telegram-api/issues/9#issuecomment-38175765
It started working for me after I updated Server IP Address in the MemoryStateAPI class, as shown below -
public void start(boolean isTest) {
connections = new HashMap<>();
connections.put(1, new ConnectionInfo[]{
new ConnectionInfo(1, 0, isTest ? "149.154.175.10" : "149.154.175.50", 443)
});
}
Yes, it's just the Datacenter IPs that are outdated. I just started using this project for learning purposes, and I quickly figured that out. Just needed to follow the stack trace ;) I forked the repo, updated the IPs and submitted a pull request (#12) ;) But until this is done, you can use my fork of the repo https://github.com/LukeLR/telegram-bot which is exactly the same code with the updated IPs ;) This should fix your issue
Do we need to configure something for the telegram-bot or it should work out-of-the-box ?
I've run the bot on the production or test servers and I get a timeout when it tries to do a rpc call in the login() method