Unable to send request (Root cause: java.net.SocketException: Socket closed

critical

#1

When sending API requests through the Web/API service, I’m able to send around 70 without issue. The data values are being read from a CSV file. However, after those 70, I receive the error:

Unable to send request (Root cause: java.net.SocketException: Socket closed

For each request.

The original 60+ request go through each run without incident. I was able to use the Postman Runner and sent 100 tests to the same API without incident. Each test was a pass with no failures.

The code used is based on the following example:
Create REST API requests manually

2019-04-01 14:53:52.384 DEBUG testcase.Postman Request                 - 5: resp = req.buildPostApiRequestDataDriven(order_id, customer_number, branch_number, tier_code, unit_measure)
2019-04-01 14:53:52.388 INFO  c.k.k.core.util.BrowserMobProxyManager   - HAR: /Users/<>/Katalon Studio/Postman Testing/Reports/Postman Data Driven/20190401_145129/requests/main/78.har
2019-04-01 14:53:52.389 ERROR c.k.k.core.keyword.internal.KeywordMain  - ❌ Unable to send request (Root cause: java.net.SocketException: Socket closed
	at com.kms.katalon.core.webservice.common.RestfulClient.sendRequest(RestfulClient.java:80)
	at com.kms.katalon.core.webservice.common.RestfulClient.send(RestfulClient.java:49)
	at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.doCall(SendRequestKeyword.groovy:53)
	at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword$_sendRequest_closure1.call(SendRequestKeyword.groovy)
	at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:66)
	at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.sendRequest(SendRequestKeyword.groovy:48)
	at com.kms.katalon.core.webservice.keyword.builtin.SendRequestKeyword.execute(SendRequestKeyword.groovy:43)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords.sendRequest(WSBuiltInKeywords.groovy:40)
	at com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords$sendRequest.call(Unknown Source)
	at mypackage.SampleRequestObject.buildPostApiRequestDataDriven(SampleRequestObject.groovy:110)

#2

To add more information to this issue, it appears to be a problem with the “data driven” portion of the test.

For example, if I use the following code, I can send 100 requests without issue.

List userName=['','Liam','Noah','William','James'] //<-- 100 names goes here
def slurper = new JsonSlurper()

for (loop = 1; loop <=userName.size()-1; loop++) {
	response1 = WS.sendRequest(findTestObject('eComm', [('name') : userName[loop]]))
	String result = slurper.parseText(response1.getResponseBodyContent())
	log.logWarning("API Response #" + loop + ": ---> " + result) 
}

If I use the same code, but set it up with a Test Suite with a CSV or XLS file of 100 names, it fails at 70 requests every time.

def slurper = new JsonSlurper()
response1 = WS.sendRequest(findTestObject('eComm', [('name') : firstName]))
String result = slurper.parseText(response1.getResponseBodyContent())
log.logWarning("API Response #: ---> " + result)

For this simple example, I have a Web Service Request object pointing to:
https://reqres.in/api/users


#3

Just to add, this also works using an XLS spreadsheet.

def slurper = new JsonSlurper()

FileInputStream file = new FileInputStream ("//location//100names.xlsx")
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);

'Read data from excel'
for (loop = 1; loop <=100; loop++) {
	String Data_fromCell=sheet.getRow(loop).getCell(0).getStringCellValue();
	response1 = WS.sendRequest(findTestObject('eComm', [('name') : Data_fromCell]))
	String result = slurper.parseText(response1.getResponseBodyContent())
	log.logWarning("API Response #" + loop + ": ---> " + result)
}

file.close();

From everything I have tried, the process of using a “data driven” file from the Test Suite sheet causes the issue.


#4

@Katalon_Studio Can someone have a look and give some advice on this?

Thanks,


#5

Thank you for the report. We are working on it.


#6

@devalex88
Hi Alex, can u pls help to give some update on this one?

Thanks.


#7

Disabling the Browser MobProxy option resolved this issue for me: https://forum.katalon.com/t/5-9-0-getting-a-java-net-socketexception-permission-denied-connect-after-update/14500