OpenTl / OpenTl.ClientApi

The Api client library that implements the MtProto 2.0. To connect to servers, such as Telegram
MIT License
80 stars 22 forks source link

Establishing connection after termination by exception #22

Closed MohammadMDSA closed 6 years ago

MohammadMDSA commented 6 years ago

Socket(connection) exception in another thread (not catch-able) causes the UpdateReceive event not to work anymore and the event doesn't give me updates anymore...

How can I make it work again? (Beside creating another IClientApi instance) And how can I check connection health during runtime?

Thanks

vik-borisov commented 6 years ago

Hi! @MohammadMDSA Can you create a sample app or test with a bug?

MohammadMDSA commented 6 years ago

It is just like the example you provided. I am running it on a .NET Core server everything works perfectly until proxy on the client instance, disconnects and reconnects again. That's when the connection gets interrupted and there is no more updates... I can create a client instance on runtime and dispose the original one(using server rest request), but I have to do that myself when I realize something's wrong.

I need to know if there a way my program checks client connection on runtime and automates renewing client instance or...

vik-borisov commented 6 years ago

@MohammadMDSA Still relevant?

bsod79 commented 6 years ago

hello, I think that I'm facing the same issue. After some time, without any error the program does not receive any other data from server. Running in debug in visual studio I saw only "thread terminated". I'm using more or less the code in the quickstart section. Everything is working fine for more or less a couple of hours, then stops.

I can try to create a sample app to replicate the issue, but the code i wuat in the quickstart (automaticreceiveupdate)

Matteo

MohammadMDSA commented 6 years ago

I started a task that disposes client object every 30minutes and re-instaciate it. It works but definitely not a clean solution...

bsod79 commented 6 years ago

I was thinking a similar solution. A timer that start after last update received and if no update for a specific time, restart everything.

Agree with you that it is not a clean solution, but if it works... I also tried implementing a "keepAlive" with a custom request (as was available in previous release) but nothing changes.

One question, Are you using automatic update or manual?

/Additional info/ I fixed a small bug in my code related to the "keepAlive" and now seems that connection is no more crashing. I'll check in the next days.

bsod79 commented 6 years ago

Hello.

Update on my side. With the keepalive the applicaiton is running smoothly since yesterday.

KeepAlive Connection, from my point of view, need to be restored.