xDB Migration process throws an exception about a canceled task


Description

When using xDB Data Migration tool 3.0.0 - 4.0.0, Sitecore analytics data might fail to migrate from Sitecore XP 8.x to Sitecore XP 9.x with an unhandled exception. The issue occurs if xConnect does not respond within a certain time (more than 30 seconds by default). The following message can be found in the log records:

An error occurred while sending the request. (pipeline: Process Single Contact from MongoDB Pipeline, pipeline step: Add Contact Model to xConnect Batch, pipeline step identifier: 46ebebbf-250f-4bc2-a5f2-e4a64b58e561)
A task was canceled. (pipeline: Process Single Contact from MongoDB Pipeline, pipeline step: Add Contact Model to xConnect Batch, pipeline step identifier: 46ebebbf-250f-4bc2-a5f2-e4a64b58e561)

Solution

To resolve the issue: