Open derodevil opened 2 years ago
Hello. Looks like you use preview version of 0.5.0
. Try to update the library.
Is this code still needed or you have updated the library where it keeps alive without the code? IDisposable KeepAlive(TelegramClient tg) =>
This code is still needed. It should be removed in ‘0.6.0’. On 15 Jan 2022, 12:03 +0100, derodevil @.***>, wrote:
Is this code still needed or you have update the library where it keeps alive without the code? IDisposable KeepAlive(TelegramClient tg) => — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
I use the latest version 0.5.1 started at 17:45 and I let it idle for more than two hours. At 21:00 I send a text message and it couldn't receive any massage. I don't think the latest version keep it alive. My code looks like this:
var contacts = await tg.Contacts.GetContacts();
... some logic with `contacts`
KeepAlive(tg); //where the `KeepAlive` is the above snippet
tg.Updates.Stream.Subscribe(
onNext: async n =>
{
try
{
... my other code when receiving a message
}
catch (Exception ex)
{
WriteLog(ex.Message)
}
},
onError: e =>
{
WriteLog(e.Message);
}
);
Hm. Can you subscribe to internal exceptions? Should look like tg.Updates.Exceptions.Subscribe(Console.WriteLine)
. KeepAlive
snippet just ignores ping exceptions. Replace .Subscribe()
with .Select(x => x.Exception).Where(x => x != null).Subscribe(Console.WriteLine)
. It should give more information for debugging.
I had been running from 11pm to 7am and no exception was caught. I've checked the log file since I put the error message to a file and nothing there.
[EDIT]
I think I find the problem here where the tg.Updates
and/or KeepAlive
method should not be placed inside a multi threaded method. I tried this approach and it keeps alive for more than two hours
Yet another reason to move KeepAlive
into the library internals
Well, I'm waiting for the next release
Do you have any updates for this issue?
Do you have any updates for this issue?
Not yet. I had started the refactoring and abandoned it. I do not have time for Telega now and the next few months. I can review and merge a PR however.
Hi.. I'm still waiting 💯
The above snippet doesn't work. My winforms application gets disconnected after 1 to 2 hours inactivity.
[EDIT] I try my own custom ping every ten seconds. After approximately an hour it generates error as follows: