DoRpcCall时的TimeOut异常 - 在TeleGram java API中导入联系人

时间:2014-12-02 06:14:37

标签: java api telegram

我正在尝试添加和导入用于发送消息的联系人,但我每次都会获得超时异常。 如果出现问题,请纠正我。

代码:

TLInputContact tlic=new TLInputContact(1, PhNo, Fname, Lname);
TLVector contacts = new TLVector<>();
contacts.add(tlic);
TLRequestContactsImportContacts importContacts = new TLRequestContactsImportContacts(contacts, true);
TLImportedContacts importedContacts = api.doRpcCall(importContacts);
TLAbsUser recipient=importedContacts.getUsers().get(0);
TLInputPeerContact peer = new TLInputPeerContact(recipient.getId());
TLRequestMessagesSendMessage sendMessageRequest = new TLRequestMessagesSendMessage(peer, "Test", rnd.nextInt());

TLAbsSentMessage sentMessage = api.doRpcCall(sendMessageRequest);

Log::
    TelegramApi#1001:Timeout Iteration
    ActorDispatcher:Dispatching action: schedule for scheduller
    ActorDispatcher:Dispatching action: schedule for scheduller
    TelegramApi#1001:Timeout Iteration
    TelegramApi#1001:RPC #3: Timeout (15001 ms)
    Exception in thread "main" org.telegram.api.engine.TimeoutException
        at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:364)
        at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:309)
        at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:400)
        at org.telegram.api.engine.TelegramApi.doRpcCall(TelegramApi.java:396)
        at testmsg.Testmsg.main(Testmsg.java:151)
        TelegramApi#1001:Timeout Iteration

2 个答案:

答案 0 :(得分:3)

在TelegramApi对象中尝试doRpcCallSide而不是doRpcCall 它帮助了我。

答案 1 :(得分:0)

在我更新了MemoryStateAPI类中的服务器IP地址后,它开始为我工作,如下所示 -

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