wiz0u / WTelegramClient

Telegram Client API (MTProto) library written 100% in C# and .NET
https://wiz0u.github.io/WTelegramClient/
MIT License
956 stars 156 forks source link

Client reconnection problem #262

Closed z6yszko closed 2 months ago

z6yszko commented 2 months ago

I encountered an issue with the client's reconnection process. If a Client.OnOther event related to ReactorError occurs, the following code works correctly:

Console.WriteLine("Disposing the client and trying to reconnect in 5 seconds...");
Client?.Dispose();
Client = null;
await Task.Delay(5000);
try
{
    await CreateAndConnect();
    break;
}
catch (Exception ex) when (ex is not ObjectDisposedException)
{
    Console.WriteLine("Connection still failing: " + ex.Message);
}

However, when there is an interruption in the internet connection, the Client.OnOther event is not triggered. The client then assumes the status of Disconnected. After restoring the internet connection, the client remains Disconnected. In this case, attempting to run the above code results in an error:

The process cannot access the file '...\WTelegram.session' because it is being used by another process.

In such a case, the command client.LoginUserIfNeeded(); also does not restore the connection. Do you know of any solution?

Igor741 commented 2 months ago

Same problem. Anyone knows how to solve this?

Igor741 commented 2 months ago

For now I receiving this error in logs:

Ignoring 0x3072CFA1 because of wrong timestamp 2024-07-02 12:16:18Z (svc)

Igor741 commented 2 months ago

updated to version 4.1.2 and everything worked