Unexpected connection reset when running CLI commands

Article ID:360053420131
2 minute readKnowledge base


  • After running any CLI command, I get the following stack trace:

javax.net.ssl.SSLException: Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Connection reset
at sun.security.ssl.SSLSocketImpl.checkEOF(SSLSocketImpl.java:1533)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:95)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)



There are some reasons why you face a networking error message when you run the jenkins-cli command. One of them is the Connection reset. In this case, the connection between the jenkins-cli command and the Jenkins server is reset by the jenkins-cli if the task requires too much time to be accomplished by the Jenkins server (like for example moving a too large folder of jobs from one controller to another one).

On this kind of error, the solution is using webSocket for the connection. Using webSocket for the connection we will prevent the timeout of the HTTP request and the jenkins-cli will wait for the Jenkins response.

To run the jenkins-cli command using webSocket you only need to add the argument -webSocket to the command. Please, take a look at the following example:

java -jar jenkins-cli.jar -s $JENKINS_URL -auth $USER:$API_TOKEN -webSocket list-plugins