wiz0u / WTelegramClient

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

something wrong with PingDelayDisconnect with multiple instances and highload #288

Closed m0nax3 closed 1 month ago

m0nax3 commented 1 month ago

I found solution for https://github.com/wiz0u/WTelegramClient/issues/287 and probably for https://github.com/wiz0u/WTelegramClient/issues/286

I'm check sources and found KeepAlive method, then change PingInterval to -60 in my app and it's work, disconnects gone. (negative value mean using simple ping instead PingDelayDisconnect )

if (PingInterval <= 0)
    await this.Ping(ping_id++);

https://github.com/wiz0u/WTelegramClient/blob/4f9accdfc80bc1e3d93f08bb1b156d217b042fd6/src/Client.cs#L993

new results = 8 hours still 2500+ instances

6 times - Unable to read data from the transport connection: Connection timed out 12 times - Could not read payload length : Connection shut down 2 times - Unable to read data from the transport connection: Connection reset by peer

now it looks like normal stable behavior but not sure how it work, maybe thread pool was busy this 15 seconds or network card, or something in SendAsync wrong

(old results) 613 times - Unable to read data from the transport connection: Connection reset by peer 837 times - Could not read payload length : Connection shut down reactor error

m0nax3 commented 1 month ago

can be closed after reading, just information