TLSharp icon indicating copy to clipboard operation
TLSharp copied to clipboard

addresses connection issues

Open solarin opened this issue 4 years ago • 5 comments

! 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.

solarin avatar Apr 08 '20 19:04 solarin

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.

knocte avatar Apr 09 '20 08:04 knocte

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

solarin avatar Apr 09 '20 08:04 solarin

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

knocte avatar Apr 10 '20 07:04 knocte

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.

solarin avatar Apr 10 '20 07:04 solarin

! 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.

davidcon avatar Aug 19 '21 06:08 davidcon