Invoke API through Selenium in Jenkins Failing - I/O exception (java.net.SocketException) caught when processing request to {}->http://RegistryServer:1505: Broken pipe

Document ID : KB000102991
Last Modified Date : 10/07/2018
Show Technical Document Details
Issue:
Trying to deploy a MAR file to the Coordinator from Selenium testing in Jenkins through Invoke API.
We are facing the following error:
Upload LISA Test Case Mar file into LISA Server. 
Jun 08, 2018 12:33:37 PM org.apache.http.impl.execchain.RetryExec execute 
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://RegistryServer:1505: Broken pipe 
Jun 08, 2018 12:33:37 PM org.apache.http.impl.execchain.RetryExec execute 
INFO: Retrying request to {}->http://RegistryServer:1505 
Jun 08, 2018 12:33:37 PM org.apache.http.impl.execchain.RetryExec execute 
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://RegistryServer:1505: Broken pipe 
Jun 08, 2018 12:33:37 PM org.apache.http.impl.execchain.RetryExec execute 
INFO: Retrying request to {}->http://RegistryServer:1505 
Start Test Case Execution. 
Test Case Id =D81C8C696B5211E8B66BFA163ED3CA7C 
Test Case Report URL =http://RegistryServer:1507/devtest/#/main/testMonitorTests/overview?testRunId=D81C8C696B5211E8B66BFA163ED3CA7C 
Environment:
All Supported DevTest releases.
Resolution:
The issue was happening only in the environment with Selenium and Jenkins executing an automated script. 
We were able to execute the commands below via Postman and Curl, and had no issues to get the valid responses: 
curl -F "file=@/opt/ca/lisa/server/File.mar" http://UserName:Password@RegistryServer.com:1505/api/Dcm/CoordinatorServers/CoordinatorName/actions/deployMar 

curl -X POST http://UserName:Password@RegistryServer.com:1505/api/Dcm/CoordinatorServers/CoordinatorName/Tests/F9E1771C5E9911E89B9FFA999ED9CA9C/actions/start 

To try to understand how the commands were getting in the Registry side, we used tcpdump in the Registry server and collected the network traffic while reproducing the issue. More information on how to capture network traffic with tcpdump in the link below:
https://comm.support.ca.com/kb/how-to-capture-network-traffic-using-tcpdump/KB000094804

When analyzing the network traffic between the Jenkins side and Registry server on port 1505, we could find several HTTP traffic with 401 unauthorized.
When doing 'follow TCP stream' we saw it was a response to the command to deploy the MAR file and there was no authorization header.
When we got a valid response for this same command, the authorization header was available.

We asked the team to modify the script used to the deploy the MAR file and make sure the credentials are sent every time we execute the POST calls.

The script was modified to pass the credentials as part of HttpPost instead of HttpClient.
After this change, we stopped seeing the SocketTimeOutException.