Title: RestAssured.baseURI get the default value and not the value I provide Why
Tags: java;rest;jenkins;ssh
Question: When I run my test on jenkins it gives following Error, I am using http port 80 and ssh port 22. Test works locally, any help would be appreciated.
- Caused by: java.net.ConnectException: Connection chaveztammy@example.net(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:121)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.apache.http.client.HttpClient$execute$0.call(Unknown Source)
Comment: Try logging into the Jenkins system to then ping / connect to the remote systems used there. Maybe some sort of firewall issue?

Comment: You should then enhance your question accordingly, and give as much of your setup/configuration information as possible.

Comment: Again, dont put additional information into comments. Edit/update your question instead. You dont want to force people to read through a gazillion of hard to read comments.

Comment: You are adding "more information" via comments. Dont do that. **Edit** your question, and add new content there. And then delete those comments that you added previously, like the one 2 hours old.

Comment: ok I have debugged and found it tries to connect to 151.154.11.224 although I have hard coded the uri and ports in jenkins job as -Dsut=151.154.11.224 -Dport=80 -DsshPort=22 but still it connects to 151.154.11.224:6080

Comment: ok I have debugged more and found it is getting 151.154.11.224 from RestAssured class in java
* The base URI that's used by REST assured when making requests if a non-fully qualified URI is used in the request.
* Default value is {@value #DEFAULT_URI}.
*/
public static String baseURI = DEFAULT_URI;
My code is as below
RestAssured.baseURI = "http://" + config.getBaseUrl();
public String getBaseUrl() {
System.out.println(this.getValue("sut"));
return this.getValue("sut");
where *sut* is defined in property file as
sut=151.154.11.224

Comment: what should I remove ?


Here is another answer: Port 80 is HTTP port. It's very likely that an HTTP server is running already on your Jebkins machine.
You need to choose another port for your tets. Make it greater than 1023 not to conflict with well-known and system ports.
Comment for this answer: Did you change the port for both your server AND your client? Do they match?
Comment for this answer: Your `this.getValue(String)` method, what does it do?
Comment for this answer: Tried other ports too
Comment for this answer: I have changed the ports, still it says connection refused, surprisingly same ports work for another test
Comment for this answer: ok I have debugged and found it tried to connect to 151.154.11.224 although I have hard coded the uri in jenkins job as -Dsut=151.154.11.224 -Dport=80 -DsshPort=22 but still it connection to   http://151.154.11.224:6080
Comment for this answer: ok, I sorted this problem by sending values as parameter and was not using them from jenkins, that was the quickest fix

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 7, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:05/31/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<java><rest><jenkins><ssh>', 'Title': 'RestAssured.baseURI get the default value and not the value I provide Why', 'ViewCount': 850, 'id': 50623457, 'user_AboutMe': '', 'user_AccountId': 10852387.0, 'user_DisplayName': 'Sara', 'user_Reputation': 143.0, 'user_Views': 69.0, 'user_id': 7979766.0}}