Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading fresh DC list timeout #2

Closed
Thus0 opened this issue Mar 7, 2014 · 6 comments
Closed

Loading fresh DC list timeout #2

Thus0 opened this issue Mar 7, 2014 · 6 comments

Comments

@Thus0
Copy link

Thus0 commented Mar 7, 2014

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

...
:app:run
Use test DC? (write test for test servers): Using production servers
Loading fresh DC list...Exception in thread "main" org.telegram.api.engine.TimeoutException
        at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:327)
        at org.telegram.api.engine.TelegramApi.doRpcCallNonAuth(TelegramApi.java:391)
        at org.telegram.api.engine.TelegramApi.doRpcCallNonAuth(TelegramApi.java:383)
        at org.telegram.bot.Application.login(Application.java:382)
        at org.telegram.bot.Application.main(Application.java:40)
@floens
Copy link

floens commented Mar 14, 2014

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.

@Thus0
Copy link
Author

Thus0 commented Mar 18, 2014

I've tested the bot on linux/gentoo (java 1.6.0_45) and perhaps it's a duplicate bug of this one : telegram-s/telegram-api-old#9 (comment) and it's related to the jvm ?

@Thus0
Copy link
Author

Thus0 commented Mar 20, 2014

It works on Windows with jvm 1.6
(no timeout) with production server :)

@floens
Copy link

floens commented Mar 20, 2014

Check out the solution everyone who came here from Google:
telegram-s/telegram-api-old#9 (comment)

@cancerian0684
Copy link

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)
        });
    }

@LukeLR
Copy link

LukeLR commented Sep 10, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants