Closed solarin closed 4 years ago
looks like that the big problem is happening with the DC 149.154.165.120
in fact, if i start the software with this default ip address, the migration to a new DC is not requested and the library immediately fails with the above exception
@aarani please help bro! thanks
@solarin can you test this PR: https://github.com/sochix/TLSharp/pull/919 maybe it fixes this problem
@solarin can you test this PR: #919 maybe it fixes this problem
i don't know if it's because i am new to github or because the source repository was deleted, but i can't find it
you could click on the diff and extract it as a patch
you could click on the diff and extract it as a patch
no luck, i have been trying for more than 1 hour, i am not able to download this thing. i give up. if @aarani is so kind to send me a copy, i'll be happy to try.
i even checked "see the repo at this time": https://github.com/sochix/TLSharp/tree/2d9aa26ba22702e64b356e98a1600c189482ce27 but then it can't be downloaded... do you know how to do it?
Download this with curl or wget: https://github.com/sochix/TLSharp/commit/2d9aa26ba22702e64b356e98a1600c189482ce27.patch then apply it to your tree
error: TLSharp.Core/Network/TLClient.cs: already exists in working directory error: patch failed: TLSharp.Core/Network/TcpTransport.cs:1 error: TLSharp.Core/Network/TcpTransport.cs: patch does not apply error: patch failed: TLSharp.Core/TLSharp.Core.csproj:9 error: TLSharp.Core/TLSharp.Core.csproj: patch does not apply error: patch failed: TLSharp.Core/packages.config:2 error: TLSharp.Core/packages.config: patch does not apply error: patch failed: TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj:7 error: TLSharp.Tests.NUnit/TLSharp.Tests.NUnit.csproj: patch does not apply error: patch failed: TLSharp.Tests.VS/TLSharp.Tests.VS.csproj:8 error: TLSharp.Tests.VS/TLSharp.Tests.VS.csproj: patch does not apply error: patch failed: TLSharp.Tests/TLSharp.Tests.csproj:9 error: TLSharp.Tests/TLSharp.Tests.csproj: patch does not apply error: patch failed: TeleSharp.Generator/App.config:1 error: TeleSharp.Generator/App.config: patch does not apply error: patch failed: TeleSharp.Generator/TeleSharp.Generator.csproj:9 error: TeleSharp.Generator/TeleSharp.Generator.csproj: patch does not apply error: patch failed: TeleSharp.TL/TeleSharp.TL.csproj:9 error: TeleSharp.TL/TeleSharp.TL.csproj: patch does not apply
by the way, this problem seems to be connected with DataCenter number 5. maybe also others, i don't know. dc4 is working fine
error: TeleSharp.TL/TeleSharp.TL.csproj: patch does not apply
How are you applying the patch? git am
or the patch
command?
Anyway, regardless of this, what happens is that the 2d9aa26ba22702e64b356e98a1600c189482ce27 commit needs to be applied into a previous commit, not current master. So, first, checkout this commit in your local clone: f24da2cbf162cba5805fd62c9649998ec4db837e, and after that, apply the patch.
git apply ok let me see
same exception
Furthermore, there is a new bug in this code
public TcpTransport(string address, int port, TcpClientConnectionHandler handler = null)
{
//if (handler == null)
//{
var ipAddress = IPAddress.Parse(address);
tcpClient = new TLClient(ipAddress, port, ReceiveMessage);
tcpClient.ConnectAsync();
//}
//else
// tcpClient = handler(address, port);
}
the call ConnectAsync might not end before someone calls send on the TcpTransport, causing an exception.
everything works if telegram migrates the communication to DC4. With other datacenters it doesn't work. how is it possible that other data centers use a different protcol?
i think i understood why this is happening :D
let me see
because some data centers only accept media!
yes, filtering the MediaOnly also fixes the problem, but ReconnectToDcAsync should also be fixed because it creates a TcpTransport, then it calls ConnectAsync which basically reloads the session with the old datacenter address and recreates a new TcpTransport.
my proposed solution is that ReconnectToDcAsync does not recreate a TcpTransport, but saves the session after updating the new datacenter. then everything stays as it is.
this is compatible with #939 and/or #937
please @knocte check asap and let's address this boring issue. we need either #939 or #937 for this fix
my proposed solution is that ReconnectToDcAsync does not recreate a TcpTransport, but saves the session after updating the new datacenter. then everything stays as it is.
Not sure what you mean by this. When explaining changes to the code, it's better to post a diff than using prose.
filtering the MediaOnly also fixes the problem
You mean this change?:
@@ -111,17 +111,16 @@ namespace TLSharp.Core
{
TLRequestExportAuthorization exportAuthorization = new TLRequestExportAuthorization() { DcId = dcId };
exported = await SendRequestAsync<TLExportedAuthorization>(exportAuthorization, token).ConfigureAwait(false);
}
- IEnumerable<TLDcOption> dcs;
+ IEnumerable<TLDcOption> dcs =
+ dcOptions.Where (d => d.Id == dcId && !d.MediaOnly);
if (dcIpVersion == DataCenterIPVersion.OnlyIPv6)
- dcs = dcOptions.Where(d => d.Id == dcId && d.Ipv6); // selects only ipv6 addresses
+ dcs = dcs.Where(d => d.Id == dcId && d.Ipv6);
else if (dcIpVersion == DataCenterIPVersion.OnlyIPv4)
- dcs = dcOptions.Where(d => d.Id == dcId && !d.Ipv6); // selects only ipv4 addresses
- else
- dcs = dcOptions.Where(d => d.Id == dcId); // any
+ dcs = dcs.Where(d => d.Id == dcId && !d.Ipv6);
TLDcOption dc;
if (dcIpVersion != DataCenterIPVersion.Default)
{
if (!dcs.Any())
i just added
dcs = dcs.Where(d => !d.MediaOnly)
after all the if-else
but there is also the ReconnectToDcAsync to change. i'll make a pr later. if i am still alive. debugging this thing is more difficult than my project :D
i can't manage to connect with my Emiratis telephone numbers. i tried 2 numbers, both same problem, same exception.