sochix / TLSharp

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

SendCodeRequestAsync error #420

Open CodyLuck opened 7 years ago

CodyLuck commented 7 years ago

Hello, Ive got an exception on console application, sending telegram messages when i try to send code request. Tryed different variants of type telephone number, no one get result. It seems to me, that ive got mistake some where, but cat`n find where. hash result is null My code down here public static void telegramWrite() { string phoneNumber = "+79****85"; string api = "965***a370"; int _user_id = 69***84; int id = 52; var store = new FileSessionStore(); var client = new TelegramClient(user_id, api, store, "session"); client.ConnectAsync(); var hash = client.SendCodeRequestAsync(phoneNumber); var code = "1234"; var user = client.MakeAuthAsync(phoneNumber, hash.Result, code); var userById = client.GetContactsAsync(); client.SendMessageAsync(new TLInputPeerUser() {user_id = _user_id }, "test"); }

knocte commented 7 years ago

Please paste here the whole exception (including stacktrace).

Also, can you try removing the "+" character from the phone number? If it works, please let us know.

CodyLuck commented 7 years ago

Thanks for quick answer!!!

After reboot a cant get that exception again, kust hash.result is null, but i found by breakpoints, why it didtn works. In client.ConnectAsync() => var result = await Authenticator.DoAuthentication(_transport); => var step1Response = step1.FromBytes(await sender.Receive()); returns that in output //*** 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\14.0.0.0b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0b77a5c561934e089\System.Windows.Forms.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0b03f5f7f11d50a3a\System.Drawing.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\14.0.0.0b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\14.0.0.0b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\шарпей\TLSharp-maste2r\TLSharp-master\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0b77a5c561934e089\System.Data.DataSetExtensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0b03f5f7f11d50a3a\Microsoft.CSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0b77a5c561934e089\System.Data.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0b03f5f7f11d50a3a\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0b77a5c561934e089\System.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\mscorlib.resources\v4.0_4.0.0.0_ru_b77a5c561934e089\mscorlib.resources.dll'. Module was built without symbols. The thread 0x16ac has exited with code 0 (0x0). The thread 0x17d4 has exited with code 0 (0x0). The thread 0x1cd0 has exited with code 0 (0x0). The thread 0x1870 has exited with code 0 (0x0). 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\шарпей\TLSharp-maste2r\TLSharp-master\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe'. Symbols loaded. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\шарпей\TLSharp-maste2r\TLSharp-master\ConsoleApplication1\bin\Debug\TLSharp.Core.dll'. Symbols loaded. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\шарпей\TLSharp-maste2r\TLSharp-master\ConsoleApplication1\bin\Debug\TeleSharp.TL.dll'. Symbols loaded. 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0b03f5f7f11d50a3a\System.Configuration.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Step into: Stepping over non-user code 'TLSharp.Core.TelegramClient.ConnectAsync' Step into: Stepping over non-user code 'TLSharp.Core.TelegramClient.d9..ctor' Step into: Stepping over non-user code 'TLSharp.Core.Auth.Authenticator.DoAuthentication' Step into: Stepping over non-user code 'TLSharp.Core.Auth.Authenticator.d__0..ctor' The thread 0xa4 has exited with code 0 (0x0). 'ConsoleApplication1.vshost.exe' (CLR v4.0.30319: ConsoleApplication1.vshost.exe): Loaded 'C:\шарпей\TLSharp-maste2r\TLSharp-master\ConsoleApplication1\bin\Debug\Ionic.ZLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Exception thrown: 'System.NullReferenceException' in TLSharp.Core.dll The thread 0x1d84 has exited with code 0 (0x0). The thread 0x1e34 has exited with code 0 (0x0). The program '[3456] ConsoleApplication1.vshost.exe' has exited with code 0 (0x0).

****////////// not exception, just that output and end of cycle.

in the same time TcpTransport.active = true, TcpTransport.connected = true. I tried defaultConnectionAddress 149.154.167.50 and 149.154.175.100. now using first, because he was in specified in app configuration in telegram registration. Port always 443.

And ive got the second question. At home ive got free internet connection, but at work it works throw proxy, How can i use proxy in project? Tyied use proxy in web config but haven`t result.

2017-03-12 18:50 GMT+03:00 Andres G. Aragoneses notifications@github.com:

Please paste here the whole exception (including stacktrace).

Also, can you try removing the "+" character from the phone number? If it works, please let us know.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sochix/TLSharp/issues/420#issuecomment-285953490, or mute the thread https://github.com/notifications/unsubscribe-auth/AZJDyihIybCStqc_Ot7qBWQTmXhhtwdYks5rlBRPgaJpZM4Makq6 .