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

Changing ServerTimeout and NetworkTimeout has no effect #268

Open
cjimenezCT opened this issue Apr 19, 2021 · 0 comments
Open

Changing ServerTimeout and NetworkTimeout has no effect #268

cjimenezCT opened this issue Apr 19, 2021 · 0 comments

Comments

@cjimenezCT
Copy link

Which service(blob, file) does this issue concern?

File

Which version of the SDK was used?

v2.0.1

On which platform were you using? (.Net Framework version or .Net Core version, and OS version)

.NET Framework 4.8

What problem was encountered?

Changing the default timeouts on CloudFileClient has no effect on the actual timeout. Related to #125

How can the problem be reproduced? It'd be better if the code caused the problem can be shared.

I'm storing a local CloudFileClient variable and using it to construct a directory reference in Azure. I tried setting both the ServerTimeout and NetworkTimeout to 1 minute, as well as MaximumExecutionTime to 3 minutes, but it still takes 15 minutes to time out the connection after I manually disconnect my machine from the internet.

Util.cs

CloudFileClient fileClient;

public static CloudFileClient GetCloudFileClient()
{
    if (fileClient == null)
    {
        fileClient = GetStorageAccount().CreateCloudFileClient();
    }

    fileClient.DefaultRequestOptions = new FileRequestOptions
    {
        ServerTimeout = TimeSpan.FromMinutes(1),
        NetworkTimeout = TimeSpan.FromMinutes(1),
        MaximumExecutionTime = TimeSpan.FromMinutes(3),
        RetryPolicy = new NoRetry()
    };

    return fileClient;
}

DMWrapperClass.cs

public static async Task UploadDirectoryToFileShareAsync(string srcPath, string destPath, CancellationToken cancellationToken, Progress<TransferStatus> progress, TransferCheckpoint transferCheckpoint)
{
    CloudFileDirectory cloudFileDirectory;
    CloudFileClient cloudFileClient;
    
    cloudFileClient = Util.GetCloudFileClient();
    cloudFileDirectory = await Util.CreateCloudFileDirectoryAsync(destPath, cloudFileClient);
    
    UploadDirectoryOptions options = new UploadDirectoryOptions { Recursive = true };
    DirectoryTransferContext directoryTransferContext = GetDirectoryTransferContext(transferCheckpoint, progress);
    directoryTransferContext.ShouldOverwriteCallbackAsync = TransferContext.ForceOverwrite;
    
    Task<TransferStatus> task;
    
    // Start the upload
    try
    {
        task = TransferManager.UploadDirectoryAsync(srcPath, cloudFileDirectory, options, directoryTransferContext, cancellationToken);
    
        while (!task.IsCompleted)
        {
            cancellationToken.ThrowIfCancellationRequested();
            break;
        }
    
        // wait for upload to finish
        var result = await task;
    
        // check for failures
        if (result.NumberOfFilesFailed > 0 && cancellationToken.IsCancellationRequested == false)
        {
            // retry
        }
    }
    catch (Exception e)
    {
        // exception handling here
    }
}

Have you found a mitigation/solution?

No

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

1 participant