我在设置Paypal时遇到了一些麻烦,似乎总是得到HttpHostConnectException
(请参阅下面的完整堆栈跟踪)我虽然这可能是防火墙的问题,但是网络团队保证他们允许通过防火墙的地址。那么有人对可能导致这种情况的原因有任何建议吗?
org.apache.http.conn.HttpHostConnectException: Connect to api-3t.sandbox.paypal.com:443 [api-3t.sandbox.paypal.com/173.0.82.83] failed: Connection timed out: connect
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:140)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:318)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
at uk.co.cdl.webclient.servicefacade.payment.PaypalPaymentService.paypalHttpCall(PaypalPaymentService.java:192)
at uk.co.cdl.webclient.servicefacade.payment.PaypalPaymentService.registerPaypalExpressCheckoutTransaction(PaypalPaymentService.java:125)
at uk.co.cdl.webclient.model.paypal.RegisterPaypalPayment.doPost(RegisterPaypalPayment.java:41)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
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 org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:239)
at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)
... 31 more
这是我的请求的Java代码
public HashMap<String, String> paypalHttpCall(final String methodName, List<NameValuePair> nvps) {
String responseText = "";
HashMap<String, String> responseNvp = null;
CloseableHttpClient httpClient = HttpClientHelper.getDefaultHttpClient(30000);
Status status = Status.HEALTHY;
String description = "Paypal Connection Successful";
addPostParameterIfNotEmpty(nvps, Paypal.METHOD, methodName);
addPostParameterIfNotEmpty(nvps, "VERSION", this.paypalEndpointVersion);
addPostParameterIfNotEmpty(nvps, "PWD", this.paypalPassword);
addPostParameterIfNotEmpty(nvps, "USER", this.paypalUsername);
addPostParameterIfNotEmpty(nvps, "SIGNATURE", this.paypalSignature);
CloseableHttpResponse postResponse = null;
try {
super.transactionStart();
/* getExternalURL() returns https://api-3t.sandbox.paypal.com/nvp
*
*/
if (!UrlHelper.isAValidFullURL(getExternalURL())) {
// shouldn't happen, but we're toasted if it does, so don't even try
throw new IllegalArgumentException("bad url: "+getExternalURL());
}
final HttpPost httpPost = new HttpPost(getExternalURL());
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));
postResponse = httpClient.execute(httpPost); // Connection timeout here
} catch (IOException ioe) {
status = Status.DEAD;
description = "We through an IOException so something bad has happened.";
ioe.printStackTrace();
} finally {
super.transactionFinish(status, description);
}
return responseNvp;
}
答案 0 :(得分:1)