rubenlagus / TelegramApi

Java library to create Telegram Clients
MIT License
300 stars 108 forks source link

TelegramApi does not end when close #38

Open ghost opened 7 years ago

ghost commented 7 years ago

After calling the close method, the connection does not end, the application continues to work.

` public class Main {

public static void main(String... args) {

    ...

    TelegramApi api = new TelegramApi(state, new AppInfo(APP_ID, "MyApp", "1.0", "1.0", "en"), new ApiCallback() {...});

    TLRequestAuthCheckPhone check = new TLRequestAuthCheckPhone();

    check.setPhoneNumber("***********");

    try {

        TLCheckedPhone checkedPhone = api.doRpcCallNonAuth(check);

        System.out.println(String.format("phone checked: %s", checkedPhone.isPhoneRegistered()));

    } catch (Exception e) {
        e.printStackTrace();
    }

    api.close();
}

} `

Console output:

TelegramApi#1001:<< #0 deserialized auth.checkedPhone#811ea28e in 10 ms TelegramApi#1001:<< #0 auth.checkedPhone#811ea28e in 4416 ms phone checked: true MTProto#1001#Scheduller:Forgetting message: #2 MTProto#1001:Response Iteration MTProto#1002#Transport2:suspend connnection org.telegram.mtproto.transport.TcpContext@42ce6238 MTProto#1002#Scheduller:Connection dies 2 java.lang.InterruptedException at java.lang.Object.wait(Native Method) at org.telegram.mtproto.MTProto$SchedullerThread.run(MTProto.java:677) MTProto#1001:Scheduller Iteration MTProto#1001:Scheduller:wait 15000 MTProto#1001:Scheduller Iteration MTProto#1001:Scheduller:wait 15000 MTProto#1001:Scheduller Iteration MTProto#1001:Scheduller:wait 15000 MTProto#1001:Scheduller Iteration MTProto#1001:doSchedule Scheduller:Prepare package: ping_delay_disconnect#f3427b8c of size 16 Scheduller:Total size: 16 MTProto#1001#Scheduller:Iteration: count: 1, confirm:3 MTProto#1001#Scheduller:Building package MTProto#1001#Scheduller:Adding msg_ack: 3 MTProto#1001#Scheduller:Adding package: #9 ping_delay_disconnect#f3427b8c (6451386954171809796, 15) MTProto#1001#Scheduller:Sending Package (6451386954171809800, 16) MTProto#1001:Schedulled in 0 ms MTProto#1001:MessagePushed (#3): time:1502080577 MTProto#1001:MessagePushed (#3): seqNo:16, msgId6451386954171809800 MTProto#1001:Scheduller Iteration etc.

c0ldd commented 6 years ago

Same problem. Any suggestion how to correctly close api ?