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?
I encountered an issue with the client's reconnection process. If a Client.OnOther event related to ReactorError occurs, the following code works correctly:
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?