获取java.net.ConnectException:连接超时但能够从同一台机器到服务器进行telnet

时间:2015-07-14 19:03:16

标签: java java-ee

我在Java代码中遇到异常。但是,当我telnet到同一台服务器时,它的工作原理。任何暗示可能会出现什么问题?

Caused by: java.net.ConnectException: Connection timed out
    at org.apache.axis.AxisFault.makeFault(AxisFault.java:129)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:131)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:150)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:120)
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:180)
    at org.apache.axis.client.Call.invokeEngine(Call.java:2564)
    at org.apache.axis.client.Call.invoke(Call.java:2553)
    at org.apache.axis.client.Call.invoke(Call.java:2248)
    at org.apache.axis.client.Call.invoke(Call.java:2171)
    at org.apache.axis.client.Call.invoke(Call.java:1691)
    at se.telenor.cpcextraservices.org.tempuri.BasicHttpBinding_CPCWS2DefStub.getServiceIDsFromAccountID(BasicHttpBinding_CPCWS2DefStub.java:451)
    at customerentrance.model.util.CPCUtil.getServicesForAccountId(CPCUtil.java:198)

    ... 78 more

Caused by: java.net.ConnectException: Connection timed out
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
    at java.net.Socket.connect(Socket.java:452)
    at java.net.Socket.connect(Socket.java:402)
    at java.net.Socket.<init>(Socket.java:309)
    at java.net.Socket.<init>(Socket.java:124)
    at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:129)
    at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:157)
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:114)

    ... 89 more

1 个答案:

答案 0 :(得分:0)

由于您的代理设置,我认为失败不在于您的程序可能是您的环境。

尝试:将-Djava.net.useSystemProxies = true添加到应用程序的运行框中,或者添加:

System.setProperty("java.net.useSystemProxies", "true");