JIRA Rest Api - Status Code: 0 Error Message:The underlying connection was closed: An unexpected error occurred on a send.

Two weeks before we had an authorization issue for API,as the JIRA Key got expired. We have updated the new key in Production config file. Since then, we have been facing this issue and after analysis we got the "Underlying connection closed " which is the actual error. I have also tried with Application Pool restart in Production servers, but still the same result. 

But the same API works fine in localmachine  using PostMan(REST Client) and in stage server as well. This api fails only in production server.

 

we are using C#.Net - Rest Client to call JIRA API, below are the details

try
            {
                RestClient client = new RestClient(ConfigurationManager.AppSettings["JiraUri"]);
                RestRequest request = new RestRequest(resource, method);
                request.AddHeader("Authorization", "Basic " + JiraAuthentication);
                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("Accept", "application/json");
                request.RequestFormat = DataFormat.Json;
                if (requestBody != null)
                {
                    request.AddBody(requestBody);
                }
                var response = client.Execute<T>(request);
                if(response.StatusCode == System.Net.HttpStatusCode.OK && response.Data != null)
                    return response.Data;
                else
                {
                    emailBody += "Status Code: " + response.StatusCode + "\n Error Message:" + response.ErrorMessage + "\n";
                    SendEmail("Admin@xxxx.com", "firstName.lastName@trane.com", "Error in accesing JIRA API", emailBody);
                    throw new Exception(response.ErrorMessage);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

The Sample URI is as below:

https://projectName.jira.com/rest/api/2/issue/AVC-3173

Error we get when we call JIRA API:

Status Code: 0

Error Message:The underlying connection was closed: An unexpected error occurred on a send.

 

Please help me in fixing this issue.

 

1 answer

0 votes
Volodymyr Krupach Community Champion Mar 15, 2017

Code 0 means that there is no response. Check:

  • Firewall restrictions for booth directions: can Java make outgoing requests and are the incoming requests enabled on the destination server.
  • For troubleshooting you may try to make the call from the server using some tool like mentioned PostMan.

 

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,033 views 6 18
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot