sochix / TLSharp

Telegram client library implemented in C#
1k stars 379 forks source link

Problem with getting files #384

Open Dian8 opened 7 years ago

Dian8 commented 7 years ago

After several successful downloads I'm getting following exception:

Couldn't read the packet length

Trace:

   at TLSharp.Core.Network.TcpTransport.<Receieve>d__4.MoveNext() in E:\tem
p\__telegram\TLSharp-master\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 t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.Network.MtProtoPlainSender.<Receive>d__7.MoveNext() in E
:\temp\__telegram\TLSharp-master\TLSharp.Core\Network\MtProtoPlainSender.cs
:line 41
--- End of stack trace from previous location where exception was thrown --
-
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.Auth.Authenticator.<DoAuthentication>d__0.MoveNext() in
E:\temp\__telegram\TLSharp-master\TLSharp.Core\Auth\Authenticator.cs:line 3
2
--- End of stack trace from previous location where exception was thrown --
-
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.TelegramClient.<ConnectAsync>d__8.MoveNext() in E:\temp\
__telegram\TLSharp-master\TLSharp.Core\TelegramClient.cs:line 54
--- End of stack trace from previous location where exception was thrown --
-
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.TelegramClient.<ReconnectToDcAsync>d__9.MoveNext() in E:
\temp\__telegram\TLSharp-master\TLSharp.Core\TelegramClient.cs:line 92
--- End of stack trace from previous location where exception was thrown --
-
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at TLSharp.Core.TelegramClient.<GetFile>d__24.MoveNext() in E:\temp\__te
legram\TLSharp-master\TLSharp.Core\TelegramClient.cs:line 314
--- End of stack trace from previous location where exception was thrown --
-
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at Telegrammer.TMedia.<ProcessFileLocationAsync>d__2.MoveNext()

Worst thing is this exception renders session file unusable. All subsequent calls to ConnectAsync() fails with exception "Can't decode packet" Session file must be removed - only after that connection can be successfully established.

Here is also stack trace for subsequent exceptions:

Unhandled Exception: System.AggregateException: One or more errors occurred
. ---> System.InvalidOperationException: Can't decode packet
   at TLSharp.Core.Network.MtProtoSender.DecodeMessage(Byte[] body) in E:\t
emp\__telegram\TLSharp-master\TLSharp.Core\Network\MtProtoSender.cs:line 11
3
   at TLSharp.Core.Network.MtProtoSender.<Receive>d__9.MoveNext() in E:\tem
p\__telegram\TLSharp-master\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 t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TLSharp.Core.TelegramClient.<ConnectAsync>d__8.MoveNext() in E:\temp\
__telegram\TLSharp-master\TLSharp.Core\TelegramClient.cs:line 74
--- End of stack trace from previous location where exception was thrown --
-
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task t
ask)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebugg
erNotification(Task task)
   at Telegrammer.Program.<RunAsync>d__22.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCan
celedExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, Cancellat
ionToken cancellationToken)
   at Telegrammer.Program.Main(String[] args)
mbj2007 commented 6 years ago

hi , can you implement as describe in this page https://core.telegram.org/mtproto/service_messages#rpc-error , this Can't decode packet this issue removed from telegram web site. i think you must renew your code