function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sushsush 

how to deal with connectException-connection refused

hi,

Iam getting the below errors,when i tried executing the sample code.

An unexpected error has occurred: ; nested exception is:

java.net.ConnectException: Connection refused: connect

AxisFault

faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException

faultSubcode:

faultString: java.net.ConnectException: Connection refused: connect

faultActor:

faultNode:

faultDetail:

{http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection refused: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(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 org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:103)

at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

at org.apache.axis.client.Call.invoke(Call.java:2767)

at org.apache.axis.client.Call.invoke(Call.java:2443)

at org.apache.axis.client.Call.invoke(Call.java:2366)

at org.apache.axis.client.Call.invoke(Call.java:1812)

at com.sforce.soap.enterprise.SoapBindingStub.login(SoapBindingStub.java:2200)

at Samples.login(Samples.java:84)

at Samples.run(Samples.java:325)

at Samples.main(Samples.java:37)

{http://xml.apache.org/axis/}hostname:hydhtc42322

java.net.ConnectException: Connection refused: connect

at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:154)

at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)

at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)

at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)

at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)

at org.apache.axis.client.Call.invokeEngine(Call.java:2784)

at org.apache.axis.client.Call.invoke(Call.java:2767)

at org.apache.axis.client.Call.invoke(Call.java:2443)

at org.apache.axis.client.Call.invoke(Call.java:2366)

at org.apache.axis.client.Call.invoke(Call.java:1812)

at com.sforce.soap.enterprise.SoapBindingStub.login(SoapBindingStub.java:2200)

at Samples.login(Samples.java:84)

at Samples.run(Samples.java:325)

at Samples.main(Samples.java:37)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(Unknown Source)

at java.net.PlainSocketImpl.connectToAddress(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 org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:103)

at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)

at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:404)

at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:138)

... 13 more

Best Answer chosen by Admin (Salesforce Developers) 
DineshramDineshram
Sush, Were you able to fix this issue? If yes, May I know, how could you fix this?

Thanks,
Dinesh

All Answers

NasipuriNasipuri
In the main method add the lines below to set proxy detail
 

System.setProperty("http.proxyHost", "");

System.setProperty("http.proxyPort", "");

It is a hosted application .So for Internet connection you have to provide proxy information.

Hope this will work.

Regards,

Dinesh Nasipuri

DineshramDineshram
Sush, Were you able to fix this issue? If yes, May I know, how could you fix this?

Thanks,
Dinesh
This was selected as the best answer
faheemfaheem

Thank u very much................I was able to solve the problem by setting these properties.

 

However I read that its a better approach to read these setting from a property file that hard coding in the class file.

 

Thanks again

faheem farhan

yagnayagna

I faced the same proxy issue when I was trying to work behind a firewall.

 

Parameters mentioned above work fine, but with a small change. 

 

        System.setProperty("proxyHost", "yourproxy.server.com");
        System.setProperty("proxyPort", "8080");

 

These lines should be included in the main loop of your code.

 

Hope this helps people out there :) 

middha.vikram@gmail.commiddha.vikram@gmail.com

Hi Faheem,

 

What proxyhost and proxyport did you use here for connecting to SFDC ?