Join 34,000+ subscribers and receive articles from our
blog about software quality, testing, QA and security.

java.net.SocketException: Connection reset when trying to connect to API


#1

Hey Team,

Goal: Import all the test cases with steps into excel. (Each step in test case should be displayed in separate row).
I am struck here with “java.net.SocketException: Connection reset” when trying to connect to the API.
Below is the code:
public static void main(String[] args) throws Exception
{
APIClient client = new APIClient(“https://XXXX.testrail.net/”);
client.setUser(“XXXX”);
client.setPassword(“XXXX”);
JSONObject c = (JSONObject) client.sendGet(“get_case/1”);
System.out.println(c.get(“title”));
}

Error:
Exception in thread “main” java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at sun.security.ssl.InputRecord.readFully(Unknown Source)
at sun.security.ssl.InputRecord.read(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.HttpURLConnection.getResponseCode(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source)
at com.gurock.testrail.APIClient.sendRequest(APIClient.java:151)
at com.gurock.testrail.APIClient.sendGet(APIClient.java:91)
at API.main(API.java:23)


#2

Hi there,

The message you are getting back looks like it may be caused by a connection issue. It is possible it is perhaps being caused by a proxy on your network. Additionally, you mentioned Excel, we also have a CSV option as well that you can leverage when importing test cases. You can also easily do this via the TestRail UI rather than using the API.

http://docs.gurock.com/testrail-userguide/howto-import-csv


#3

Hey Thanks for your response.

As mentioned earlier the CSV doesn’t serve the purpose. We have developed
our customized code to pull the information in the format that we need in
Excel using the API. But banging my head why I was getting this error.

Thanks & Regards,
Sridhar Upputuri


#4

Hey Sridhar,

At this point have you been able to get around the error?


#5

No still I am getting same Connection reset issue when try to access the API from any IDE. But I am able to connect and get the data from postman successfully.

Not sure what us wrong when trying with IDE (I tried with Java eclipse and Python Pycharm)