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

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

203 views 1 3
Join discussion

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