sochix / TLSharp

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

add handler for exception with code 32 #910

Open n3nikita opened 4 years ago

n3nikita commented 4 years ago

Add handler for exception with code 32. #668 and #777 issues.

knocte commented 4 years ago

What does this achieve? It just says "add handler", does this mean it is the fix for #668 and #777?

n3nikita commented 4 years ago

Yes. I've just PR the code from issue #668 which should fix error with code 32.

knocte commented 4 years ago

This is very weird code.

@CheshireCaat can you review?

CheshireCaat commented 4 years ago

I think there is a more correct way to get rid of this error. How can I repeat it to make sure that this solution is right?

CheshireCaat commented 4 years ago

Okay, I looked at issues related to this problem, I think we need a more global solution for working with parallel requests as well. Maybe it will be better to add something like SemaphoreSlim to the SendRequestAsync or RequestWithDcMigration?

CheshireCaat commented 4 years ago

Now the code from the example below will throw errors

await Task.WhenAll(Enumerable.Range(1, 5).Select(arg => Client.CheckUsernameAsync("CheshireCaat")))

I tested it also with modified RequestWithDcMigration with SemaphoreSlim - it works fine. Can you check your error by adding Semaphore? If this helps, I think it's better to do it that way.

CheshireCaat commented 4 years ago

@n3nikita ping