Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File located on a different DC #52

Open
ReshetovAnton opened this issue Oct 7, 2021 · 1 comment
Open

File located on a different DC #52

ReshetovAnton opened this issue Oct 7, 2021 · 1 comment

Comments

@ReshetovAnton
Copy link

ReshetovAnton commented Oct 7, 2021

I have a problem. If, when trying to send a request TLRequestGetUserPhotos, the user's photo is located on another DC, the library will migrate the user to the required DC. But on the next request, there will already be a user_migration_error error. The current library functionality in the ReconnectToDcAsync method does not solve this problem in any way.

I came to a solution, just skip files that are on a different DC.

private async Task RequestWithDcMigration(TLMethod request, CancellationToken token = default(CancellationToken), int attempt = 0)
        {
            if (sender == null)
                throw new InvalidOperationException("Not connected!");

            var completed = false;
            while (!completed)
            {
                try
                {
                    await sender.Send(request, token).ConfigureAwait(false);
                    await sender.Receive(request, token).ConfigureAwait(false);
                    completed = true;
                }
                catch (DataCenterMigrationException e)
                {
                    //File located on a different DC:
                    if(e.Message.IndexOf("File located on a different DC:") != -1)
                        throw new Exception("naher nado poka");
                    if (Session.DataCenter.DataCenterId.HasValue &&
                        Session.DataCenter.DataCenterId.Value == e.DC)
                    {
                        throw new Exception($"Telegram server replied requesting a migration to DataCenter {e.DC} when this connection was already using this DataCenter", e);
                    }

                    await ReconnectToDcAsync(e.DC, token).ConfigureAwait(false);
                    // prepare the request for another try
                    request.ConfirmReceived = false;
                }
            }
        }

Help please, can anyone come across this.

@SmaGMan
Copy link

SmaGMan commented Nov 2, 2021

Hi!
I fixed it in this commit
SmaGMan@f081731

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

No branches or pull requests

2 participants