tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

GetChat/LoadChat not work #2985

Closed littleboyonearth closed 3 months ago

littleboyonearth commented 3 months ago

before sendMsg, I tried

client.send(new TdApi.LoadChats(new TdApi.ChatListMain(), 100)`, handler);
client.send(new TdApi.GetChats(new TdApi.ChatListMain(), 100), handler);     
client.send(new TdApi.GetChat(chatId), new UpdateHandler());

but just get

Error {
  code = 400
  message = "Chat not found"
}

this error is caused by the last line, getChatById.

and after sendMsg, same response received.

pls help.

littleboyonearth commented 3 months ago

what I know: if local db not init, or the first launch, then getChat has to happen before sendMsg. so after succeeding authentication, I tried to loadChat, which had no effect, without any related response received, so I tried to getChatById, which just resulted in the 400 error as above showed.

levlam commented 3 months ago

You must receive the chat from TDLib first before you can use its identifier. You can do this in exactly the same way you would do from a GUI app.

littleboyonearth commented 3 months ago

after adjusting the log level, I see what happens. it's a net proxy problem. when logLevel set to 0, there is no any related logs output. Thank you for support!

littleboyonearth commented 3 months ago

I set proxy during sometime before, and later, I comment the setting lines

client.send(new TdApi.AddProxy(proxyServer, proxyPort, true, new TdApi.ProxyTypeSocks5()), null);

and relaunch, I thought that will not bypass proxy, but the logs suggests that TDLib remember the proxy setting before and use it even later I don't set. this behavior is just like an app(even though you run the program just like a command line ), set and remember, and must disableProxy explicitly if you don't want a proxy. Hope this will help someone.