It's all about the answers!

Ask a question

RTC 6.0: Connection timed out: connecting to RTC through Plain Java API


Naveen Tyagi (19723140) | asked Jun 14 '16, 2:12 a.m.
I have been trying to connect to RTC through Plain Java API but getting Connection timed out error. I suspect the issue due to proxy so i set the Proxy:
System.setProperty("https.proxyHost", "proxy");
System.setProperty("https.proxyPort", "80");

but still getting same error. If i run the code for local server on same network it is working fine. can any one suggest something to fix this issue? Thanks in advance.

public List<ProjectInformation> getProjectAreas()
    {
        List<ProjectInformation> projectList = new ArrayList<ProjectInformation>();
        RTCRepositoryInformation repoInformation =  new RTCRepositoryInformation();
        //ITeamRepository currentRepository = repoInformation.getCurrentRepository();
        ITeamRepository currentRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository("https://Myserver.com/ccm");
       
        if(currentRepository != null) {
            // If having an ID for the user as string
            //IContributor user = teamRepository.contributorManager().fetchContributorByUserId(user)\
           
            if(!currentRepository.loggedIn() )
            {
                currentRepository.registerLoginHandler(new MyLoginhandler());
                try {
                    currentRepository.login(null);
                } catch (TeamRepositoryException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.out.println(" login "+ currentRepository.loggedIn());
            }

Here is the complete error on console:

java.net.ConnectException: Connection timed out: connect
    at sun.nio.ch.Net.connect(Native Method)
    at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:552)
    at com.ibm.team.repository.transport.client.InterruptableSocketFactory.doConnect(InterruptableSocketFactory.java:142)
    at com.ibm.team.repository.transport.client.InterruptableSocketFactory.createSocket(InterruptableSocketFactory.java:69)
    at com.ibm.team.repository.transport.client.SecureInterruptableSocketFactory.createSocket(SecureInterruptableSocketFactory.java:300)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at com.ibm.team.repository.transport.client.ClientHttpUtil.executePrimitiveRequest(ClientHttpUtil.java:1293)
    at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:372)
    at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:322)
    at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:220)
    at com.ibm.team.repository.transport.client.ClientHttpUtil.executeHttpMethod(ClientHttpUtil.java:229)
    at com.ibm.team.repository.transport.client.RestClientConnectionBase.executeMethod(RestClientConnectionBase.java:324)
    at com.ibm.team.repository.transport.client.RestClientConnectionBase.doMethod(RestClientConnectionBase.java:187)
    at com.ibm.team.repository.transport.client.RestClientConnectionBase.doGet(RestClientConnectionBase.java:122)
    at com.ibm.team.repository.transport.client.TeamRawRestServiceClient$RawRestClientConnection.doGet(TeamRawRestServiceClient.java:96)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invokeServiceCall(ServiceInterfaceProxy.java:254)
    at com.ibm.team.repository.client.internal.ServiceInterfaceProxy.invoke(ServiceInterfaceProxy.java:110)
    at com.ibm.team.repository.client.internal.RawRestServiceClientProxy$RestClientConnectionProxy.invoke(RawRestServiceClientProxy.java:121)
    at com.sun.proxy.$Proxy9.doGet(Unknown Source)
    at com.ibm.team.repository.client.internal.TeamRepository.fetchClientVersionJSONObject(TeamRepository.java:1666)
    at com.ibm.team.repository.client.internal.TeamRepository.access$0(TeamRepository.java:1663)
    at com.ibm.team.repository.client.internal.TeamRepository$5.run(TeamRepository.java:1734)
    at com.ibm.team.repository.client.internal.TeamRepository$5.run(TeamRepository.java:1)
    at com.ibm.team.repository.client.internal.TeamRepository$3.run(TeamRepository.java:1325)
    at com.ibm.team.repository.common.transport.CancelableCaller.call(CancelableCaller.java:79)
    at com.ibm.team.repository.client.internal.TeamRepository.callCancelableService(TeamRepository.java:1320)
    at com.ibm.team.repository.client.internal.TeamRepository.checkServerVersionMatches(TeamRepository.java:1737)
    at com.ibm.team.repository.client.internal.TeamRepository.internalLogin(TeamRepository.java:1513)
    at com.ibm.team.repository.client.internal.TeamRepository.login(TeamRepository.java:654)
    at com.ibm.team.repository.client.internal.TeamRepository.login(TeamRepository.java:628)
    at com.fca.systemdesk.plugin.internal.rtc.RTCSourceControlHandler.getProjectAreas(RTCSourceControlHandler.java:66)
    at com.fca.systemdesk.plugin.internal.rtc.RTCSourceControlHandler.main(RTCSourceControlHandler.java:108)

2 answers



permanent link
Kenny Smith (287412) | answered Jun 14 '16, 4:23 p.m.
Double check your host name for typos. See if you can ping it. 

Also, I don't see TeamPlatform.startup(); in your script. You need that before you call the 
TeamPlatform.getTeamRepositoryService().getTeamRepository(REPOSITORY);

I would recommend writing a JUnit test that confirms the connection params, and makes the connection. Its a bit faster than debugging, and you can also debug into a JUnit test (which is much faster than debugging the entire system). 

Comments
Naveen Tyagi commented Jun 14 '16, 11:39 p.m.

Hi Kenny,
I have done that in main method. I will take your adivice but the issue is i'm able to do that at local server but getting error at proxy server located somewhere else and request passing through proxy.


permanent link
Donald Nong (14.4k314) | answered Jun 14 '16, 9:33 p.m.
It does not make sense using System.setProperties() to set the proxy configuration in your own code. Try to set it instead as a JVM runtime (command line) parameter. Also note that you may use http.proxyHost and http..proxyPort rather than https.proxyHost and https.proxyPort.

Comments
Naveen Tyagi commented Jun 15 '16, 12:58 a.m.

Hi Donald,

I have set the JVM proxy but still bad luck.

java -Dhttp.proxyHost=webcache.mydomain.com -Dhttp.proxyPort=8080



Donald Nong commented Jun 15 '16, 3:01 a.m.

Which version of RTC are you using? Hopefully you're not affected by this defect.


Also, you need to make sure whether an HTTP proxy, or HTTPS proxy is in use. Judging by the port number, it appears that you're using an HTTP proxy, which should be OK.

Your answer


Register or to post your answer.