Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Connection Timeout in Workflow Post Function Script Edited

Hi,

In my service desk project, on issue creation workflow there is a post-function running a script. 

The script includes a web service query . But usually the web service got connection timeout error. We controlled the network connections and permissions but cant find the root cause.

At the jira server when we write to browser  this 

http://****/****rest/service/get****/********

The response is to quick.

But when it is running in post-function script, it goes timeout.

Timeout set time is 20 seconds. I think it is enough.

"The script is for find the issue reporter's manager and add the manager for approve the issue."

 

this is the script :

import groovy.json.JsonSlurper;
import groovy.json.StreamingJsonBuilder;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue
import org.apache.commons.codec.binary.Base64;
import groovy.json.JsonBuilder;
import com.atlassian.jira.user.ApplicationUser;
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.customfields.option.LazyLoadedOption;

def log = Logger.getLogger("*******")
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userManager = ComponentAccessor.getUserManager();

//for debug

def issueManager = ComponentAccessor.getIssueManager()

def usermail = issue.getReporter().getEmailAddress();
def baseURL="";

def cField = customFieldManager.getCustomFieldObject("customfield_****")
def cFieldValue = issue.getCustomFieldValue(cField)
if(cFieldValue){
def selectedValue = ((LazyLoadedOption)cFieldValue).getValue()
if(selectedValue.equals("******")) {
baseURL = "http://*****/*****/********/rest/service/get****/" + usermail + "/2";
}else{
baseURL = "http://*****/***/***/********/rest/service/get***/" + usermail + "/1";
}
}else return;


//set Url
def URL url;
url = new URL(baseURL);
//create Json Builder
def data = new JsonBuilder();

//make sure custom field value is not empty
//connection settings
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.requestMethod = "GET";
//connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type","application/json;charset=utf-8");
connection.setUseCaches(false);

//connect
connection.connect();

//debug
log.setLevel(Level.DEBUG)
log.debug connection.getResponseCode();
log.debug connection.getResponseMessage();
log.debug connection.getInputStream();
DataInputStream wr = new DataInputStream(connection.getInputStream());
String asdf = wr.readLine()
log.debug asdf;

if(asdf!=null){
String[] list=asdf.split(",");

List<ApplicationUser> newApprovers = [];

for(String asdf1 : list){
if(asdf1 != null && asdf1 != ""){

asdf1 = asdf1.replace("@*********","").trim();

ApplicationUser user = userManager.getUserByName(asdf1);

if(user!=null){
newApprovers.add(user);
}
}
}

}

 

Could anyone help.? Thank You.

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Jira Service Management

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

182 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you