Skip to content

Getting DataCenterMigrationException after Downloading Photo or File #56

@pahager

Description

@pahager

Hello everyone, as Title said I am getting DataCenterMigrationException after downloading any File or Photo
here is my code for downloading Photo:

` var photo = (((TLMessageMediaPhoto)((TLMessage)message).Media).Photo as TLPhoto);
// get photo
TLPhotoSize photoSize = photo.Sizes.ToList().OfType().Last();

                                                var mb = 1048576;
                                                var upperLimit = (int)Math.Pow(2, Math.Ceiling(Math.Log(photoSize.Size, 2))) * 4;
                                                var limit = Math.Min(mb, upperLimit);

                                                var currentOffset = 0;

                                                var fileLocation = new TLInputPhotoFileLocation()
                                                {
                                                    AccessHash = photo.AccessHash,
                                                    Id = photo.Id,
                                                    FileReference = photo.FileReference,
                                                    ThumbSize = photoSize.Type,
                                                };

                                                using (var fs = File.OpenWrite("TestFile.jpg"))
                                                {
                                                    while (currentOffset < photoSize.Size)
                                                    {
                                                        var file = this.TelegramClient.GetFile(fileLocation, limit, currentOffset).ConfigureAwait(false).GetAwaiter().GetResult();
                                                        fs.Write(file.Bytes, 0, file.Bytes.Length);
                                                        currentOffset += file.Bytes.Length;
                                                        Thread.Sleep(500);
                                                    }
                                                    fs.Close();
                                                }`

so when I am trying to get another message or call any other Method I am getting this Exception and in Output i can see those lines:
"TgSharp.Core.Network.Exceptions.UserMigrationException" in mscorlib.dll
"TgSharp.Core.Network.Exceptions.UserMigrationException" in TgSharp.Core.dll
"TgSharp.Core.Network.Exceptions.UserMigrationException" in mscorlib.dll
"TgSharp.Core.Network.Exceptions.UserMigrationException" in TgSharp.Core.dll
...

Anyone knows how to handle this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions