Commit graph

231 commits

Author SHA1 Message Date
Andres G. Aragoneses 60a3c62357 Core: avoid possible infinite loop if switching to same DC
People are reporting that under some circumstances, an infinite
loop could happen when TLSharp tries to handle a reconnection to
a different DC, if the DC instructed to be used is the same as
the one that was used in the last connection.

Not sure how could this happen (although the analysis present in
this github issue [1] might help understand it), but this commit
helps to make TLSharp fail fast (with an exception) instead of an
infinite loop from now on, which will help avoiding people file
issues such as [2] and [3] and instead maybe file a proper bug
report easier to understand, to try to fix the underlying root
cause.

[1] https://github.com/sochix/TLSharp/issues/719
[2] https://github.com/sochix/TLSharp/issues/803
[3] https://github.com/sochix/TLSharp/issues/839
2019-02-10 13:53:46 +01:00
Andres G. Aragoneses d04ddb1e0e Core: fix 2 warnings 2019-02-10 13:36:37 +01:00
Marc R Kellerman f2a394ea15 Fixed OffSet paramets for GetUserDialogsAsync & GetHistoryAsync (#831)
Fixes https://github.com/sochix/TLSharp/issues/696

Fixes https://github.com/sochix/TLSharp/issues/597
2019-01-04 18:16:35 +08:00
vlad_neg 47e973823a issue#768 fix exception 'Constructor Invalid Or Context.Init Not Called !' 2018-05-30 07:31:03 +08:00
Ilya Pirozhenko 1aa63e565a
Update README.md 2018-04-25 19:02:57 +03:00
Ilya Pirozhenko faf129e636
Update README.md 2018-04-25 13:23:29 +03:00
Ilya Pirozhenko 28b83aaec3
Update README.md
Removed gitter as it too noisy
2018-04-24 10:47:03 +03:00
Afshin Arani fdcb195fbb Use ToArray instead of GetBuffer
Buffer normally contain lots of extra zero bytes
2018-04-13 09:51:26 +08:00
Andres G. Aragoneses 4197df89aa
Merge pull request #732 from MasihAkbari/master
README.md: fix compilation error for getting dialogs in code snippet
2018-03-21 09:28:16 +08:00
Masih Akbari 0ff9980cc9 fix compilation error for getting dialogs in README.md file 2018-03-21 01:53:48 +03:30
Andres G. Aragoneses f8f31ddb19
Merge pull request #728 from MasihAkbari/master
README.md: update to support new PascalCase changes in the API and fix other things
2018-03-19 17:22:17 +08:00
Masih Akbari 27fcd8242c update README.md to support new PascalCase changes of API and some other fixes 2018-03-19 07:57:59 +03:30
Andres G. Aragoneses bd7f5f09eb Core(MtProtoSender): mark immutable fields as readonly
To make sure they are kept immutable when upcoming
devs make changes to this file.
2018-03-05 03:54:21 +08:00
Andres G. Aragoneses e6250b1234 Core(MtProtoSender): remove mutation-based dangerous API
It wasn't being used internally, and the use-case to be used
externally is too intricated. There's already a way to change
the handler at contructor time[1] so that should be enough
customization.

[1] 48077961ae
2018-03-05 03:54:21 +08:00
Andres G. Aragoneses 3762664c14 Normalize line endings 2018-03-04 00:39:23 +08:00
Andres G. Aragoneses c1ce5e25ba
README.md: add link to gitter channel et-al 2018-03-02 11:35:21 +08:00
Andres G. Aragoneses bf568d80cc TelegramClient: change Connect() to return void instead of always true
If a method that returns bool is never returning false,
it's essentially not giving any information at all, which
means that it should return void. This will help the
consumers of this API to stop thinking that the result
of this function means if the connection was succesful
(which it is, actually, but it was never returning false
because if there's any problem connecting, the result would
be an exception instead).
2018-03-01 23:41:35 +08:00
Andres G. Aragoneses 4ce0f72d6d TelegramClient: move the _sender null check to RequestWithDcMigration()
The method IsPhoneRegisteredAsync() was calling
RequestWithDcMigration() which was the real method
that made use of the _sender field, so we can move
the null check to there.

This will also help track down possible NullReferenceExceptions
that could happen when other callers of this method
arrive with a bad _sender, which might aid us trying
to fix #706.
2018-02-28 08:43:28 +08:00
Ilya Pirozhenko fe2baf5110
Update README.md 2018-01-23 13:34:28 +03:00
Andres G. Aragoneses 687eca968a
Merge pull request #659 from PROger4ever/master
Make Session constructor public for custom ISessionStore imlementations
2017-12-18 00:09:43 +08:00
PROger4ever 7cbc40a090 Make Session constructor public for custom ISessionStore implementations
Load() method in ISessionStore requires public constructor of class Session in some cases.
E.g., loading session from a db or a key-value store, manual loading from text-file, JSON/XML and so on.
2017-12-17 21:04:11 +05:00
Robert Massa 0940d3d982 Prepare requests for re-sending after a DC migration
Fixes #608.
2017-11-21 21:02:51 +08:00
Andres G. Aragoneses b55b28fa5d
Merge pull request #629 from aarani/master
Handle Import & Export Authorization While Reconnecting
2017-11-16 19:16:46 +08:00
Afshin Arani d15d87833e Remove Old FileMigrationException Handler
this catch block could never be reached anymore because of changes
proposed in #622
2017-11-16 14:04:24 +03:30
Afshin Arani 1877c9061c Handle Import & Export Authorization While Reconnecting
closes #624
2017-11-16 14:03:31 +03:30
Afshin Arani 659becfd51 Make TLVector implement IList 2017-11-09 20:10:22 +08:00
Afshin Arani d769dd3c2f Generator Must Respect MS .NET API guidelines 2017-11-09 19:37:09 +08:00
Robert Massa 3ba3ea53fd Handle DataCenterMigration exceptions in all methods exposed by TelegramClient
This handles the data center migration in more cases.
Fixes bugs like mentioned in #599.
2017-11-08 09:54:05 +08:00
Daniel Vygolov 0015cf494b Added new type of DataCenterMigrateException - NetworkMigrateException
Now we catch not only PhoneMigrateException but all DataCenterMigrationExceptions and reconnect
Fixes #568
2017-09-29 01:09:48 +08:00
Afshin Arani 133b9fdf6c TL-Layer: Update To Layer 66 (#519)
* TL-Layer: Update To Layer 66
2017-07-20 10:07:24 +08:00
AmiNadim 0d55940c12 Added while loop to MakeAuthAsync method. (#477)
fix PhoneMigrationException by reconnecting to DC on the error .
(fix for #458)
2017-05-18 21:06:33 +08:00
Ilya Pirozhenko 97a593e25e Update README.md 2017-05-04 18:01:13 +03:00
salarcode c5187ae12b Implementing IsConnected
Closes #460
2017-04-26 13:18:17 +08:00
Ilya Pirozhenko 1697db9d7f Update README.md 2017-02-28 16:45:20 +03:00
Barsham Sotoudeh 26aa35b88a Add missing "offset" parameter in catch block of the GetFile method (#402)
This offset optional parameter was added in a753a1ab13
2017-02-17 23:16:55 +08:00
Ilya Pirozhenko f6ef04ed01 Update README.md 2017-01-29 17:06:22 +03:00
Andres G. Aragoneses fbe8c9bf84 Merge pull request #373 from Starli0n/master
Http proxy authentication
2017-01-27 20:23:44 +08:00
Starli0n 48077961ae Custom TCP hanlder to allow HTTP proxy auth 2017-01-27 10:58:47 +01:00
Andres G. Aragoneses 85c206cc24 Merge pull request #372 from Starli0n/master
Add offset parameter to GetFile() method
2017-01-20 10:03:06 +08:00
Starli0n a753a1ab13 Add offset parameter to GetFile() method 2017-01-19 19:31:27 +01:00
Andres G. Aragoneses 5ddd9a3ad0 Merge pull request #362 from Starli0n/master
Add GetHistoryAsync() to TelegramClient
2017-01-11 17:53:25 +08:00
Starli0n 5e6cf48490 Add GetHistoryAsync() to TelegramClient 2017-01-09 18:25:55 +01:00
Mikhail 47d1c10c9d Search user by username with send message test. (#356)
* Search user by username with send message test.
2016-12-28 22:37:34 +08:00
Andres G. Aragoneses 0428753b2b Merge pull request #350 from salarcode/master
Tests: Use OfType() instead of GetType() == typeof()
2016-12-21 17:07:07 +08:00
Salar Khalilzadeh dfc89dc3ab Tests: Use OfType() instead of GetType() == typeof() 2016-12-20 12:21:18 +03:30
Andres G. Aragoneses 6d73c0e964 Merge pull request #344 from salarcode/master
Implement IDisposable in TelegramClient class
2016-12-16 15:00:46 +08:00
salar2k fc09dba71b Implementing IDisposable 2016-12-16 10:25:33 +03:30
Ilya Pirozhenko 3ef3ff86ad Merge pull request #323 from mykolasglinskis/master
FloodExceptionShouldNotCauseCannotReadPackageLengthError
2016-12-15 11:00:06 +03:00
Mykolas Glinskis e191b59233 Tests: include testcase for "couldn't read packet length" bug
It seems that after triggering a FloodException, and waiting the required time
to be able to use Telegram again, TLSharp throws an exception. I include the
way to reproduce this bug as an [Ignore]d test with the hope that someone
may help me fix the problem soon.

For reference, the whole stacktrace of the exception was:

Test Name:	FloodExceptionShouldNotCauseCannotReadPackageLengthError
Test FullName:	TLSharp.Tests.TLSharpTestsVS.FloodExceptionShouldNotCauseCannotReadPackageLengthError
Test Source:	D:\Projects\GitHub\TLSharp\TLSharp.Tests.VS\TLSharpTestsVs.cs : line 72
Test Outcome:	Failed
Test Duration:	0:04:30.7467012

Result StackTrace:
at TLSharp.Core.Network.TcpTransport.<Receieve>d__4.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Core\Network\TcpTransport.cs:line 39
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.Network.MtProtoSender.<Receive>d__9.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Core\Network\MtProtoSender.cs:line 139
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.TelegramClient.<ConnectAsync>d__8.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Core\TelegramClient.cs:line 76
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Tests.TLSharpTests.<CheckPhones>d__54.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Tests\TLSharpTests.cs:line 329
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at TLSharp.Tests.TLSharpTestsVS.<CheckPhones>d__9.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Tests.VS\TLSharpTestsVs.cs:line 68
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at TLSharp.Tests.TLSharpTests.<FloodExceptionShouldNotCauseCannotReadPackageLengthError>d__55.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Tests\TLSharpTests.cs:line 340
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at TLSharp.Tests.TLSharpTestsVS.<FloodExceptionShouldNotCauseCannotReadPackageLengthError>d__10.MoveNext() in D:\Projects\GitHub\TLSharp\TLSharp.Tests.VS\TLSharpTestsVs.cs:line 73
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Result Message:
Test method TLSharp.Tests.TLSharpTestsVS.FloodExceptionShouldNotCauseCannotReadPackageLengthError threw exception:
System.InvalidOperationException: Couldn't read the packet length
2016-11-30 09:34:44 +01:00
Ilya Pirozhenko c22ee8dea6 Merge pull request #317 from unn4m3d/patch-1
Catch PhoneMigrationException in IsPhoneRegisteredAsync
2016-11-28 09:56:40 +03:00