title: Atlassian.JIRA GetIssueAsynch throwing exception - connection closed unexpectedly
body: <p>We’ve been using Atlassian.JIRA to update Jira tickets for a few years now in our C# .Net project. Recently it has started failing to get issues from JIRA.</p>
  <p>I connect to the Jira server successfully, but Issues.GetIssueAsync() throws an exception:</p>
  <blockquote>
  <p>Error Message: The request was aborted: The connection was closed
  unexpectedly.</p>
  </blockquote>
  <p>After enabling the Request/Response trace, it looks like the response from the server is correct. The issue ID I’m trying to get exists, and the exception is thrown for any issue I try to get.</p>
  <p>We are using Atlassian.NET SDK v12.1.0.0. I’ve updated to 12.4.0.0 but the issue persists.</p>
  <p>Can anyone give some insight as to why this is occurring? What can I do to get more information on the exception being thrown?</p>
  <p><strong>Steps to reproduce:</strong></p>
  <ol>
  <li>Connect to Jira Server using JIRA.CreateRestClient()</li>
  <li>Try to get issue with specified ID using Issues.GetIssueAsync(“JIRA-ID”)</li>
  <li>Exception is thrown</li>
  </ol>
  <p><strong>Code snippet:</strong></p>
  <pre><code>Jira _jiraConnection;
  
  private bool ConnectToServer()
  {
      try
      { 
        var settings = new JiraRestClientSettings(){EnableRequestTrace = true};
        System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
        _jiraConnection = Jira.CreateRestClient(&quot;URL&quot;, &quot;USER&quot;, &quot;PASSWORD&quot;, settings);
        return true;
      }
      catch (Exception ex)
      {
        return false;
      }
  }
  
  public void UpdateJira()
  {
      if (ConnectToServer())
      {
        Issue issue;
        try
        {
          issue = await _jiraConnection.Issues.GetIssueAsync(@&quot;JIRA-ID&quot;);
        }
        catch (Exception ex)
        {
          // exception: 
          // Exception thrown: 'System.InvalidOperationException' in mscorlib.dll
          // ex.Message = Error Message: The request was aborted: The connection was closed unexpectedly.
          return;
        }
  
        ...
      }
  }
  </code></pre>
  <p><strong>.Net stack trace:</strong></p>
  <blockquote>
  <p>at
  Atlassian.Jira.Remote.JiraRestClient.GetValidJsonFromResponse(IRestRequest
  request, IRestResponse response)\r\n at
  Atlassian.Jira.Remote.JiraRestClient.d__11.MoveNext()\r\n
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
  task)\r\n at
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task)\r\nat
  Atlassian.Jira.Remote.IssueService.d__18.MoveNext()\r\n
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
  task)\r\n at
  System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
  task)\r\n at
  System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at
  PreBuild.JiraUpdater.d__11.MoveNext() in
  C:\...\JiraUpdater.cs:line 109</p>
  </blockquote>
  <p><strong>Request/Response Trace:</strong></p>
  <blockquote>
  <p>[GET] Request Url:
  rest/api/2/issue/ST-9256?fields=*all,-comment,-attachment,-issuelinks,-subtasks,-watches,-worklog</p>
  <p>[GET] Response for Url:
  rest/api/2/issue/ST-9256?fields=*all,-comment,-attachment,-issuelinks,-subtasks,-watches,-worklog</p>
  </blockquote>