java.net.ConnectException: Connection refused.. :(
513516Oct 23 2006 — edited Oct 25 2006Hi,
I am currently facing an issue with HTTP POST from Oracle Application Server.
We have a custom java class that uses HTTPClient.HTTPConnection to post data to a third party website from Oracle Apps.
The code posts data and reads response properly initially when the apache server is bounced but after a while, we keep getting the
following error. It works fine again once the apache is bounced/erstarted.
I am not sure if it is an issue with the code not closing any sockets/connections on the server or an issue with Oracle Application Server.
Appreciate any kind of inputs.
The stack trace is as follows:-
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:336)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:201)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:188)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.connect(Socket.java:428)
at java.net.Socket.<init>(Socket.java:335)
at java.net.Socket.<init>(Socket.java:179)
at HTTPClient.HTTPConnection.getSocket(HTTPConnection.java:1912)
at HTTPClient.HTTPConnection.sendRequest(HTTPConnection.java:2922)
at HTTPClient.HTTPConnection.handleRequest(HTTPConnection.java:2150)
at HTTPClient.HTTPConnection.setupRequest(HTTPConnection.java:3561)
at HTTPClient.HTTPConnection.Post(HTTPConnection.java:2494)
at HTTPClient.HTTPConnection.Post(HTTPConnection.java:2621)
at HTTPClient.HTTPConnection.Post(HTTPConnection.java:2515)
The foll. is an extract of the code in our class which extends HTTPClient.HTTPConnection
InputStream in=null;
String data="";
Collection keys=params.keySet();
Iterator it=keys.iterator();
NVPair form_data[] = new NVPair[params.size()];
String pName="";
String pValue="";
for(int i=0;i<params.size();++i)
{
pName=(String)it.next();
pValue=(String)params.get(pName);
form_data=new NVPair(pName, pValue);
}
try{
CookieModule.setCookiePolicyHandler(null);
HTTPResponse rsp = Post(method,form_data);
if (rsp.getStatusCode() >= 300)
{
System.err.println("Received Error, status code=: "+rsp.getStatusCode());
//System.err.println(rsp.getText());
}
else
{
//System.out.println(rsp.getText());
in=rsp.getInputStream();
}
catch(ModuleException ex)
{
NMHRLogger.logException(l_strMethodName + " - ModuleException("+ex.toString() +")",ex);
throw ex;
}
catch(Exception ex)
{
NMHRLogger.logException(l_strMethodName + " - ModuleException("+ex.toString() +")",ex);
throw ex;
}
finally
{ stop();
}
Once again, thanks for the inputs.
Thanks
Kesava