sochix / TLSharp

Telegram client library implemented in C#
1.01k stars 380 forks source link

addresses connection issues #931

Open solarin opened 4 years ago

solarin commented 4 years ago

! IsConnected is restored as it was before

knocte commented 4 years ago

guys, i think we should push this fix asap, i have been testing on a software which has been running for half a day now, perfectly handling the reconnection. before this fix, it could last only 30 minutes.

You make it sound like if this PR fixed connection problems. It doesn't. It just allows the developer to reconnect using the same instance of TelegramClient. You could have done the same before by creating a new TelegramClient instance.

solarin commented 4 years ago

guys, i think we should push this fix asap, i have been testing on a software which has been running for half a day now, perfectly handling the reconnection. before this fix, it could last only 30 minutes.

You make it sound like if this PR fixed connection problems. It doesn't. It just allows the developer to reconnect using the same instance of TelegramClient. You could have done the same before by creating a new TelegramClient instance.

true, but still a great improvement

knocte commented 4 years ago

Hey Mario I wrote an alternative PR with much simpler change, wouldn't that achieve the same as this?: https://github.com/sochix/TLSharp/pull/937

solarin commented 4 years ago

Hey Mario I wrote an alternative PR with much simpler change, wouldn't that achieve the same as this?: #937

yes, it looks fine and easier. let me test it for a couple of hours.

davidcon commented 3 years ago

! IsConnected is restored as it was before

  • TcpTransport has got a new Connect method which properly initializes the underlying tcpclient, this makes it possible to reconnect in case the tcpClient gets disconnected, without restarting the application or recreating a new TelegramClient object.

Excuse me @solarin I don´t know how to use your new version. I have downloaded the master branch and I have compiled it. Then I have try to use IsConnected as it shuld be but it´s always set true. Do I have to use any new method to know that the client is disconected? Or should I have to use await client.ConnectAsync(true) in stead of await client.ConnectAsync()?

I have researched some papers and I think that the problem is caused by TCP client. It´s not posible to know if que the socket is open in real time. Maybe usefull an special connection mode based in some kind of keep alive tcp socket: https://www.py4u.net/discuss/709629

Thank you very much for you time.