Reputation: 12093
I'm having a little trouble setting up Paypal and seem to be getting a HttpHostConnectException
all the time (See full stacktrace below) I though that this could be an issue with the firewall but the networks team have guaranteed that they are allowing the address through the firewall. So does anyone have any suggestions on what might be causing this?
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
Here's my Java code for the request
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;
}
Upvotes: 1
Views: 1017
Reputation: 16833
According to the discussion with the OP in the comment section, I'm pretty sure it's a firewall issue. It's impossible to connect through telnet
with the port 443, whatever the target, google or paypal.
This diagram, found in this answer is pretty useful when you are stuck like this :
Upvotes: 3