TgSharp
TgSharp copied to clipboard
`System.InvalidOperationException: Couldn't read the packet length` when trying to run AuthUser test in macOS
System.InvalidOperationException : Couldn't read the packet length
Stack trace:
at TgSharp.Core.Network.TcpTransport.Receive (System.Threading.CancellationToken token) [0x000d5] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/Network/TcpTransport.cs:59
at TgSharp.Core.Network.MtProtoSender.Receive (TgSharp.TL.TLMethod request, System.Threading.CancellationToken token) [0x0003a] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/Network/MtProtoSender.cs:144
at TgSharp.Core.TelegramClient.RequestWithDcMigration (TgSharp.TL.TLMethod request, System.Threading.CancellationToken token) [0x0010d] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/TelegramClient.cs:178
at TgSharp.Core.TelegramClient.SendCodeRequestAsync (System.String phoneNumber, System.Threading.CancellationToken token) [0x0009b] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/TelegramClient.cs:208
at TgSharp.Tests.TgSharpTests.AuthUser () [0x000cd] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Tests/TgSharpTests.cs:129
at TgSharp.Tests.TgSharpTestsNUnit.AuthUser () [0x00020] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Tests.NUnit/Test.cs:21
at TgSharp.Core.Network.TcpTransport.Receive (System.Threading.CancellationToken token) [0x000d5] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/Network/TcpTransport.cs:59
at TgSharp.Core.Network.MtProtoSender.Receive (TgSharp.TL.TLMethod request, System.Threading.CancellationToken token) [0x0003a] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/Network/MtProtoSender.cs:144
at TgSharp.Core.TelegramClient.RequestWithDcMigration (TgSharp.TL.TLMethod request, System.Threading.CancellationToken token) [0x0010d] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/TelegramClient.cs:178
at TgSharp.Core.TelegramClient.SendCodeRequestAsync (System.String phoneNumber, System.Threading.CancellationToken token) [0x0009b] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Core/TelegramClient.cs:208
at TgSharp.Tests.TgSharpTests.AuthUser () [0x000cd] in /Users/knocte/Documents/Code/TgSharpLAITEUX/src/TgSharp.Tests/TgSharpTests.cs:129
at NUnit.Framework.AsyncInvocationRegion+AsyncTaskInvocationRegion.WaitForPendingOperationsToComplete (System.Object invocationResult) [0x0003c] in <65d21fba48bf4534bebbb82a4e22f339>:0
at NUnit.Core.NUnitAsyncTestMethod.RunTestMethod () [0x00013] in <65d21fba48bf4534bebbb82a4e22f339>:0
Try removing Session.dat inside TgSharp.Tests.NUnit\bin\Debug
@aarani why would a session.dat file cause this? can you explain?
because TgSharp doesn't handle 404 error (auth_key not found caused by auth_key being wrong/corrupted) and 404 error causes TgSharp to throw this exception. for debugging it more, set a breakpoint on "throw" line, run binaryreader(whatever it's name is).ReadInt32() It should give you the error code .
The fact that why that auth_key gets corrupted needs more debugging I saw @Laiteux comment in #18 which stated that our current FileSessionStore is corrupting AuthKey sometimes which is worrisome if true and can be the culprit here.
Check if it happens with JsonFileSessionStore
because TgSharp doesn't handle 404 error (auth_key not found caused by auth_key) and 404 error causes TgSharp to throw this exception.
that doesn't explain anything related to a .dat file?
Check if it happens with JsonFileSessionStore
well, in fact I was testing this on a branch with JSON files, but I still don't understand how the session store could be related to this?
which stated that our current FileSessionStore is corrupting AuthKey
I don't find that comment; can you repeat it @Laiteux ?
that doesn't explain anything related to a .dat file?
I don't understand what you're asking, can you rephrase that?
I don't find that comment; can you repeat it @Laiteux ?
https://github.com/nblockchain/TgSharp/pull/18#issuecomment-691866813
I don't understand what you're asking, can you rephrase that?
To your sentence "Try removing Session.dat", I asked "why would a session.dat file cause this? can you explain?", and you said some things which are completely unrelated to the session.dat file. How can that be related?
#18 (comment)
Matt is talking about the .dat file getting corrupted. That file happens to have an auth_key but I don't think he's saying anything related to authentication or networking (which is what this github issue is about).
why would a session.dat file cause this? can you explain?
because that's the place we store the authorization key and if you have broken session.dat It causes that error.
Ok as I said in Telegram to the author I mistaken "Couldn't read the packet length" with "Can't decode packet" (LOL). So all I said isn't really related to this error. It's probably some compatibility issue with Mono in mac and TgSharp since then the author is going to try using our new .NET Standard version and see if it fixes anything