title: I've got an Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host exception
body: <p>i've upgraded to the net core 6 and upgraded RestSharp to the 107.0.3 version.
  File upload to OneDrive API (Upload large files with an upload session), i've got an exception <em>'Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.'</em></p>
  <p>The first POST call to get a temp upload URL i've received a uploadUrl (<strong>https</strong>://api.onedrive.com/rup/.........). But when i did a call to it, i've got an exception.
  <a href="https://i.stack.imgur.com/9Ia7k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Ia7k.png" alt="enter image description here" /></a></p>
  <p>When i downgraded to the RestSharp version 106.15.0 everything is working as expected.</p>
  <p>My assumption, it's something wrong with the SSL configuration in HttpClient. Bc, in version 107.x RestSharp change 'HttpWebRequest' to the 'HttpClient'.
  <a href="https://restsharp.dev/v107/#restsharp-v107" rel="nofollow noreferrer">https://restsharp.dev/v107/#restsharp-v107</a></p>
  <p>I've can't quickly find a solution to fix this, so I've just downgraded to 106.x version.</p>
  <p>Maybe somebody knows a solution and shares it here.</p>
  <p>Source code:</p>
  <pre><code>var resource = &quot;URL&quot;;
  var request = CreateRequest(accessInfo.Token, resource, Method.POST);
  request.AddJsonBody($&quot;{{ \&quot;@microsoft.graph.conflictBehavior\&quot;: \&quot;replace\&quot;, \&quot;name\&quot;: \&quot;{fileName}\&quot; }}&quot;);
  var response = await _graphApiClient.ExecuteAsync(request);
  if (!response.IsSuccessful)
       {
       throw GenerateException(&quot;Can't create a upload session.&quot;, resource, $&quot;{folderPath}/{fileName}&quot;, response);
       }
  
  var fileContentType = fileName.GetFileType().GetContentType();
  var uploadSessionUrl = Map&lt;FileUploadSession&gt;(response.Content).UploadUrl;
  var sessionClient = new RestClient(uploadSessionUrl);
  var sessionRequest = new RestRequest(string.Empty, Method.PUT);
  sessionRequest.AddHeader(&quot;Content-Length&quot;, fileBytes.Length.ToString());
  sessionRequest.AddHeader(&quot;Content-Range&quot;, $&quot;bytes 0-{(fileBytes.Length - 1).ToString()}/{fileBytes.Length}&quot;);
  sessionRequest.AddHeader(&quot;Content-Type&quot;, fileContentType);
  sessionRequest.AddParameter(fileContentType, fileBytes, ParameterType.RequestBody);
  
  var sessionResponse = await sessionClient.ExecuteAsync(sessionRequest);
  if (!sessionResponse.IsSuccessful)
          {
              throw GenerateException(&quot;can't upload file to session storage.&quot;, uploadSessionUrl, $&quot;{folderPath}/{fileName}&quot;, response);
          }
  
  private RestRequest CreateRequest(string accessToken, string resource, Method method)
      {
          var request = new RestRequest(resource, method);
          request.AddHeader(&quot;Authorization&quot;, $&quot;Bearer {accessToken}&quot;);
          request.AddHeader(&quot;Content-Type&quot;, Constants.ContentTypeJson);
          request.AddHeader(&quot;Accept&quot;, Constants.ContentTypeJson);
          request.RequestFormat = DataFormat.Json;
  
          return request;
      }
  </code></pre>