Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Sometimes "Couldn't read the packet length" under Linux (.Net Core) #1013

Open
mightywill opened this issue Jan 27, 2021 · 4 comments
Open

Comments

@mightywill
Copy link

mightywill commented Jan 27, 2021

When I try to send message from Kestrel webserver under Linux that was some time in idle state(no requests) then a first two attempts fail with "Couldn't read the packet length" or "Broken pipe" but the 3rd and the following succeed

Couldn't read the packet length

System.InvalidOperationException
Couldn't read the packet length
at TlSharp.TLSharp.Core.Network.TcpTransport.Receive(CancellationToken token)
at TlSharp.TLSharp.Core.Network.MtProtoSender.Receive(TLMethod request, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.RequestWithDcMigration(TLMethod request, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.SendRequestAsync[T](TLMethod methodToExecute, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.SendAuthenticatedRequestAsync[T](TLMethod methodToExecute, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.GetUserDialogsAsync(Int32 offsetDate, Int32 offsetId, TLAbsInputPeer offsetPeer, Int32 limit, CancellationToken token)

@mightywill mightywill changed the title Couldn't read the packet length - on Linux Sometimes "Couldn't read the packet length" on Linux Jan 27, 2021
@mightywill
Copy link
Author

System.IO.IOException
Unable to read data from the transport connection: Broken pipe.
at TlSharp.TLSharp.Core.Network.TcpTransport.Send(Byte[] packet, CancellationToken token)
at TlSharp.TLSharp.Core.Network.MtProtoSender.Send(Byte[] packet, TLMethod request, CancellationToken token)
at TlSharp.TLSharp.Core.Network.MtProtoSender.Send(TLMethod request, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.RequestWithDcMigration(TLMethod request, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.SendRequestAsync[T](TLMethod methodToExecute, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.SendAuthenticatedRequestAsync[T](TLMethod methodToExecute, CancellationToken token)
at TlSharp.TLSharp.Core.TelegramClient.GetUserDialogsAsync(Int32 offsetDate, Int32 offsetId, TLAbsInputPeer offsetPeer, Int32 limit, CancellationToken tok

@mightywill mightywill changed the title Sometimes "Couldn't read the packet length" on Linux Sometimes "Couldn't read the packet length" under Linux (.Net Core) Jan 27, 2021
@novelhawk
Copy link

novelhawk commented Feb 8, 2021

Can reproduce on Windows 10 19042.746 with .NET Core 5.0.102 and TLSharp version 0.1.0.574 (NuGet).
Happens frequently on multiple methods. (threw on ConnectAsync and SendCodeRequestAsync)

EDIT: I assume this is due to .NET Core and .NET Framework incompatibilities

@MKalloub
Copy link

MKalloub commented Feb 17, 2021

Hi @novelhawk, @mightywill
Same error I got on Windows Server 2016 with ASP.NET MVC app
I'm using .NET framework 4.7.2, and TLSharp version 0.1.0.574 (NuGet)
Mostly message sent, but sometime I got the following error

Couldn't read the packet length

at TLSharp.Core.Network.TcpTransport.d__5.MoveNext()
--- 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.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()
at TLSharp.Core.Network.MtProtoSender.d__8.MoveNext()
--- 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.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at TLSharp.Core.TelegramClient.d__11.MoveNext()
--- 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.ValidateEnd(Task task)

@novelhawk
Copy link

It seems that there are known incompatibilities in using this library in core environment. (See #687 #893 #763)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants