Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Change Retries and Timeout of RTC connection from Java Plain API script

Hello,

I am doing some code with RTC API Java Plain which connect into RTC and then perform some actions.
In the part of my code which connect to RTC and login, I added a try/catch sentences so if the server is unavailable,
then I can catch the exception and give some custom message:

def loginRTC(repositoryUri, user, passwd){


 try {
  TeamPlatform.startup();
 
  // Login to the repository using the provided credentials
  ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryUri)
  repository.registerLoginHandler(new ILoginHandler2() {
   @Override
   public ILoginInfo2 challenge(ITeamRepository arg0) {
    return new UsernameAndPasswordLoginInfo(user, passwd)
   }
  });
  repository.login(new SysoutProgressMonitor())
  
  return repository
 }
 catch (Exception e) {
     println "\tError message is: " + e.getCause() + ", String: " + e.getCause().toString()
  return -1
 }
 /*catch (AuthenticationException e) {
  return -1
 }*/
}


But what I see in my console output is that the connection retries many times until it throws an error with timeout:

Trying to connect into RTC....
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
INFO  I/O exception (java.net.ConnectException) caught when processing request: Connection timed out: connect
INFO  Retrying request
        Error message is: java.net.ConnectException: Connection timed out: connect, String: java.net.ConnectException: Connection timed out: connect

So, my question is:
Is there a way to specify that do not perform retries? Or to specifify a limited number or retries and timeout to connect in RTC from my script?

Thanks a lot for the help.

0 votes


Accepted answer

Permanent link
I see the problem is to check if the server is up and running.

In this case, I'd recommend to just check if the server is alive or not. For example, if ping is allowed, then java net inetaddress isreachable() might be easy solution. Another is to create http session and try to obtain login page of RTC. If these succeeds, then you can try login procedure.



Tiago Fernandez selected this answer as the correct answer

0 votes

Comments

Thank you very much for the response.
As your recommendation, I added a previous step which checks first if RTC server is alive or not and this approach works very good. I did it using the second option you mentioned, with the http session.

Thank you very much for the help.
Regards.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,935
× 478
× 411
× 343
× 169

Question asked: Sep 10 '13, 11:13 a.m.

Question was seen: 7,450 times

Last updated: Sep 16 '13, 8:22 a.m.

Confirmation Cancel Confirm