In restassured am getting the "java.net.ConnectException: Connection refused: connect" if I execute the below function tu3 from a different class. If I call the function from parent class, it is successfully executed. Please let me know how to correct this.
#Parameters({"Param 1","Param 2"})
#Test
public void tu3(#Optional String la, #Optional int StatusCode ) throws
IOException
System.out.println("Test"+la);
System.out.println(URI);
given().pathParam("user_ID", la)
.when().delete("/{user_ID}")
.then().statusCode(StatusCode);
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
here is the problem i guess userid is double quotes
.when().delete("/{user_ID}")
Correct line should be
.when().delete("URL/"+user_ID)
Your URL should be URL/1 where 1 is user_id, not URL/{user_id}
You should pass userID to be deleted
In .delete you should provide whole API URL
Related
I'm having some issues for creating a simple socket, I'm new to this kind of stuff sorry for a simple question thanks. I tried to follow some tutorial for creating Sockets in java and tried this so far
try {
Socket chatSocket = new Socket("127.0.0.1", 4242);
System.out.println("connection established");
}
catch (IOException e) {
e.printStackTrace();
}
I'm getting this kind of error
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at application.main.main(main.java:15)
and when I try to access my localhost from my browser I see this error
The connection to '127.0.0.1' failed.
Error: ConnectionRefused (0x274d).
System.Net.Sockets.SocketException No connection could be made because the
target machine actively refused it 127.0.0.1:4242
I have no idea what is happening because, just followed what the tutorial does. I think the issue is on my local machine but I have no idea what is making the connection refuse
i have this very simple java class where i try to run a H2 DB like this:
public static void main(String[] args) {
Connection conn = null;
try {
Class.forName("org.h2.Driver");
Server server = Server.createTcpServer("-tcpPort", "50001", "-tcpAllowOthers").start();
conn = DriverManager.getConnection(
"jdbc:h2:tcp://localhost/~/H2TestDB/SMPS_DK", "sa", "sa");
I tried to copy what i found here and in the H2 doc already but for some reason the connection gets refused. I tried to find the solution here but havent been successfull so far. FYI: I am kind of a rookie so it would be great to get a more detailed answer if possible ;) Thanks in advance!
Here comes the stacktrace:
> org.h2.jdbc.JdbcSQLException: Verbindung ist unterbrochen: "java.net.ConnectException: Connection refused: connect: localhost"
Connection is broken: "java.net.ConnectException: Connection refused: connect: localhost" [90067-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:457)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:334)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:116)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:100)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at connection.Main.main(Main.java:26)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.h2.util.NetUtils.createSocket(NetUtils.java:103)
at org.h2.util.NetUtils.createSocket(NetUtils.java:83)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:115)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:453)
... 7 more
I am trying to create customers account in my recurly account.
I got private key as i have created an account in recurly for the development purpose.
with that key and Domain name i am trying to add customers details into my recurly account.
For testing purpose i am just randomly creating an account id and first name in Account object and sending it to recurly account(my account).
But during connecting to Recurly server i am getting below error.
I have verified the connection it seems ok. from web i am able to login and connect to recurly server.
public static void main(String[] args) {
// TODO Auto-generated method stub
// key and domain were correctly written
final String apiKey = "******";
final String Domain = "*****";
Account account = new Account();
account.setAccountCode(UUID.randomUUID().toString());
account.setFirstName("Jeet");
RecurlyClient recurlyClient = new RecurlyClient(apiKey, Domain);
// opening the recurly server.
recurlyClient.open();
// creating account
recurlyClient.createAccount(account);
Error logs:
3559 [main] ERROR com.ning.billing.recurly.RecurlyClient - Execution error
java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused: connect
at com.ning.http.client.providers.jdk.JDKFuture.get(JDKFuture.java:139)
at com.ning.http.client.providers.jdk.JDKFuture.get(JDKFuture.java:114)
at com.ning.billing.recurly.RecurlyClient.callRecurly(RecurlyClient.java:936)
at com.ning.billing.recurly.RecurlyClient.callRecurlySafe(RecurlyClient.java:905)
at com.ning.billing.recurly.RecurlyClient.doPOST(RecurlyClient.java:875)
at com.ning.billing.recurly.RecurlyClient.createAccount(RecurlyClient.java:172)
at ClientTesting.main(ClientTesting.java:24)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
at com.ning.http.client.providers.jdk.JDKAsyncHttpProvider$AsyncHttpUrlConnection.configure(JDKAsyncHttpProvider.java:556)
at com.ning.http.client.providers.jdk.JDKAsyncHttpProvider$AsyncHttpUrlConnection.call(JDKAsyncHttpProvider.java:232)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I am trying to access a VM from an RMI client in my machine using VM DNS NAME and port 1099 after setting an endpoint with this port but I get a refused to connect to the VM. How can I tackle this problem?
this is the error I got
D:\Dropbox\client\xxxxxxx>java -Djava.rmi.server.hostname=xx.xx.xx.xx -cp . client
java.rmi.ConnectException: Connection refused to host: xx.xx.xx.xx; nested exception is: java.net.ConnectException:
Connection timed out: connect at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source) at
sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source) at
sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source) at
sun.rmi.server.UnicastRef.invoke(Unknown Source) at
HelloImpl_Stub.getHelloMessage(Unknown Source) at
client.main(client.java:18)
Caused by: java.net.ConnectException:
Connection timed out: connect at
java.net.DualStackPlainSocketImpl.connect0(Native Method) at
java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at
java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at
java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at
java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at
java.net.SocksSocketImpl.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.(Unknown Source) at
java.net.Socket.(Unknown Source) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source) at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source) ... 6 more
I have a problem with access the gmail from my working area. This is my code. It works in my home when network settings are default. The main problem is, in the working area there is more security on computers and network like firewalls etc..
I have to find a solution for run this script behind the firewall. Closing the firewall is not a permanent solution.
Also I added the error message to the below. Any help is appreciated.
`com.sun.mail.util.MailConnectException: Couldn't connect to host, port: imap.gmail.com, 993; timeout -1;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:672)
at javax.mail.Service.connect(Service.java:345)
at javax.mail.Service.connect(Service.java:226)
at unreadmails.MailReader.<init>(MailReader.java:23)
at unreadmails.MailReader.main(MailReader.java:12)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:297)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:229)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:116)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:115)
at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:689)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:638)
... 4 more`