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

bgovindaraj March 15, 2017

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

1 vote
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 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 Sign up to answer