It's all about the answers!

Ask a question

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


Tiago Fernandez (5351619) | asked Sep 10 '13, 11:13 a.m.
retagged Sep 16 '13, 8:22 a.m. by Ralph Earle (25739)

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.

Accepted answer


permanent link
Takehiko Amano (1.3k3741) | answered Sep 11 '13, 4:42 a.m.
JAZZ DEVELOPER
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

Comments
Tiago Fernandez commented Sep 14 '13, 11:51 a.m.

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 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.