Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Setting connection or socket timeouts for the Jira Rest API

Roger Crerie February 13, 2018

We have been using the Jira REST API for a few months in a product we are creating. We have recently been made to move to different development systems in a different lab.  We are now seeing from our code is a sporadic java.lang.RuntimeException: java.net.ConnectException.  We ARE using http and https proxies and these are being set via the System.setProperties() call.  The code we are using that is seeing this problem is

 

JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri,
                _restClientContext.getUserName(), _restClientContext.getPassWord());
        _logger.info("Connected to JIRA server : " + _restClientContext.getJiraServer());

        User user = null;
        int retry = 0;
        RuntimeException exception = new RuntimeException("No problem");
        while (retry < 10) {
            try {
                Promise<User> promise = restClient.getUserClient().getUser(_restClientContext.getUserName());
                user = promise.claim();

 

I am not seeing the exceptions ALL the time with this code (meaning sometimes the getUserClient() call works) and prior to us having to move to a new lab environment we never had a problem with this code. I am guessing that it has something to do with a timeout somewhere down in the bowls of the http code.  Is there a proper way to get a Socket or Connection timeout so we can increase it to see if this helps. I am guessing that we are going to promise.claim() and that the connection closes before we are able to get our result back (due to something going on in our lab network environment).

 

Roger

 

1 answer

0 votes
Fabio Racobaldo _Herzum_
Community Champion
February 12, 2022

Hi @Roger Crerie ,

please try using factory as follow :

JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
        JiraRestClient restClient = factory.createWithBasicHttpAuthentication(...AS SPECIFIED IN YOUR CODE...)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events