The underlying connection was closed exception

Hi.
We are getting next error in trying to change user login email via API:
System.Net.Http.HttpRequestException: An error occurred while sending the request. —> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. —> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. —> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Our code:
public async Task UpdateUserEmail(string auth0Id, string email)
{
ManagementApiClient auth0Client = this.GetAuth0ManagementApiClientWithCustomHandler(await this.GetAuthToken(), new Uri(_auth0Settings.APIManagementUrl));
UserUpdateRequest userRequest = new UserUpdateRequest()
{
Email = email
};
var auth0User = await auth0Client.Users.UpdateAsync(auth0Id, userRequest);
}

We are using Auth0 3.6 SDK.

Could someone advice why are we getting this and how to fix.
Looks like it happens after upgrade to .Net 4.7.2 and Auth0 3.6.

1 Like

We get a similar issue with the token endpoint that is a SocketException with “Connection reset by peer” message. It’s intermittent but enough to cause issues with our testing.