Exception timeout for telegram java client

I used the java api telegram to communicate with the telegram api kernel in the idea of ​​intellij windows

https://github.com/ex3ndr/telegram-api


But the application encounters a Timeout error in the line
TLConfig config = api.doRpcCall(new TLRequestHelpGetConfig());

Full source code:

AppInfo appinfo=new AppInfo(45687, "Myapp", "154", "587","en");
    TLRequestAuthCheckPhone checkRequest = new TLRequestAuthCheckPhone("96521452365");


    MyApiStorage state=new MyApiStorage();
    TelegramApi api = new TelegramApi(state, appinfo, new ApiCallback()
    {
        public void onApiDies(TelegramApi api) {
            // When auth key or user authorization dies
        }
        @Override
        public void onUpdatesInvalidated(TelegramApi api) {
            System.out.print("############################### onUpdatesInvalidated");
            // When api engine expects that update sequence might be broken
        }

        @Override
        public void onAuthCancelled(TelegramApi ta) {
            System.out.print("############################### onAuthCancelled");
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        public void onUpdate(TLAbsUpdates updates) {
            System.out.print("############################### onUpdate");
            System.out.println("user Id ::::"+((TLUpdateShortMessage) updates).getFromId());

        }
    });
    api.switchToDc(1);
    TLConfig config = api.doRpcCall(new TLRequestHelpGetConfig());
    System.out.print("############################### config" + config.getTestMode());
    state.updateSettings(config);
    api.doRpcCall(checkRequest, new RpcCallbackEx<TLCheckedPhone>() {
        public void onConfirmed() {
            System.out.print("############################### onConfirmed");
        }

        public void onResult(TLCheckedPhone result) {
            boolean invited = result.getPhoneInvited();
            boolean registered = result.getPhoneRegistered();
            System.out.print("############################### onResult" + registered);
            // TODO process response further
        }

        public void onError(int errorCode, String message) {
            System.out.print("############################### onError" + message);
        }
    });



can anyone help me

0
source share
1 answer

Your timeout may occur for several reasons:
1. You are using

    api.doRpcCall (new TLRequestHelpGetConfig ());

In the TelegramApi class, this means

    return this.doRpcCall (method, timeout, 0);

0 DC. DC , -
2. doRpcCallSide, , . ,

    return this.doRpcCall(method, 15000, this.primaryDc, true);

true authRequired.
3. ,

api.doRpcCallNonAuth
+2

All Articles