AWS API Gateway - Connection timeout on accessing API using Spring RestTemplate in Java where it works fine using PostmanSpring RestTemplate timeoutAppium: Getting connection error when trying to launch Android serverFirefox web browser 50.1.0 is not opening with Selenium webdriver 3.0.1 and Java 1.8Spring RestTemplate Connection Timeout is not workingNo valid certificate for website under test produbile? (using HTMLUnit / Java)NoHttpResponseException when certificate can't be verifiedSimple POST request to API Gateway from jdk1.6.0_45 using Apache Http Client 4.5.3Internet Explorer is not opening from selenium 2.48 for JavaJavafx SSL client configuration to consume my Spring boot ssl secured Rest ApiGetting exception is java.net.SocketException: Connection reset
Alternatives to Network Backup
Term used to describe a person who predicts future outcomes
To what extent should we fear giving offense?
Can I get a PhD for developing educational software?
What ways are there to "PEEK" memory sections in (different) BASIC(s)
Journal published a paper, ignoring my objections as a referee
Template factorial function without template specialization
Get contents before a colon
Is this position a forced win for Black after move 14?
STM32 cannot reach individual registers and pins as PIC
What is the sound/audio equivalent of "unsightly"?
Printing a list as "a, b, c." using Python
How does attacking during a conversation affect initiative?
Is there a better way to use C# dictionaries than TryGetValue?
Why nature prefers simultaneous events?
Why is there not a willingness from the world to step in between Pakistan and India?
Did ancient peoples ever hide their treasure behind puzzles?
Why does this London Underground poster from 1924 have a Star of David atop a Christmas tree?
What should be done with the carbon when using magic to get oxygen from carbon dioxide?
How do you say "half the time …, the other half …" in German?
How to reply to people who accuse me of putting people out of work?
How do Barton (Hawkeye/Ronin) and Romanov (Black Widow) end up on the Benatar on Morag in 2014?
Did the Apollo Guidance Computer really use 60% of the world's ICs in 1963?
Looking for a plural noun related to ‘fulcrum’ or ‘pivot’ that denotes multiple things as crucial to success
AWS API Gateway - Connection timeout on accessing API using Spring RestTemplate in Java where it works fine using Postman
Spring RestTemplate timeoutAppium: Getting connection error when trying to launch Android serverFirefox web browser 50.1.0 is not opening with Selenium webdriver 3.0.1 and Java 1.8Spring RestTemplate Connection Timeout is not workingNo valid certificate for website under test produbile? (using HTMLUnit / Java)NoHttpResponseException when certificate can't be verifiedSimple POST request to API Gateway from jdk1.6.0_45 using Apache Http Client 4.5.3Internet Explorer is not opening from selenium 2.48 for JavaJavafx SSL client configuration to consume my Spring boot ssl secured Rest ApiGetting exception is java.net.SocketException: Connection reset
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have created an API on AWS API Gateway. When I access this using postman it works fine but when I am trying to access this in java using Spring RestTemplate, it gives me connection time out error. I tried with below different rest client approaches. But no luck. Not sure what mistake I am doing in code below.
Please note, I changed URI and IPs in below code/exception as I don't want to disclose actual URl and IPs.
Approach-1
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Approach-2
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate(requestFactory);
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Getting below exception when I call API using above java/spring code.
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://xyz.execute-api.us-east-1.amazonaws.com/dev/dynamodb/users/55": Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:743)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:310)
at com.adp.taxcredits.connector.icims.services.CachingServiceImpl.main(CachingServiceImpl.java:46)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:87)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:734)
... 3 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 16 more
java amazon-web-services aws-api-gateway resttemplate
add a comment |
I have created an API on AWS API Gateway. When I access this using postman it works fine but when I am trying to access this in java using Spring RestTemplate, it gives me connection time out error. I tried with below different rest client approaches. But no luck. Not sure what mistake I am doing in code below.
Please note, I changed URI and IPs in below code/exception as I don't want to disclose actual URl and IPs.
Approach-1
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Approach-2
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate(requestFactory);
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Getting below exception when I call API using above java/spring code.
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://xyz.execute-api.us-east-1.amazonaws.com/dev/dynamodb/users/55": Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:743)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:310)
at com.adp.taxcredits.connector.icims.services.CachingServiceImpl.main(CachingServiceImpl.java:46)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:87)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:734)
... 3 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 16 more
java amazon-web-services aws-api-gateway resttemplate
As a test can you try using theOkHttp3ClientHttpRequestFactory
?
– Darren Forsythe
Mar 27 at 22:30
add a comment |
I have created an API on AWS API Gateway. When I access this using postman it works fine but when I am trying to access this in java using Spring RestTemplate, it gives me connection time out error. I tried with below different rest client approaches. But no luck. Not sure what mistake I am doing in code below.
Please note, I changed URI and IPs in below code/exception as I don't want to disclose actual URl and IPs.
Approach-1
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Approach-2
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate(requestFactory);
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Getting below exception when I call API using above java/spring code.
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://xyz.execute-api.us-east-1.amazonaws.com/dev/dynamodb/users/55": Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:743)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:310)
at com.adp.taxcredits.connector.icims.services.CachingServiceImpl.main(CachingServiceImpl.java:46)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:87)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:734)
... 3 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 16 more
java amazon-web-services aws-api-gateway resttemplate
I have created an API on AWS API Gateway. When I access this using postman it works fine but when I am trying to access this in java using Spring RestTemplate, it gives me connection time out error. I tried with below different rest client approaches. But no luck. Not sure what mistake I am doing in code below.
Please note, I changed URI and IPs in below code/exception as I don't want to disclose actual URl and IPs.
Approach-1
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Approach-2
CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
RestTemplate restTemplate = new RestTemplate(requestFactory);
final String uri = "https://xyz.execute-api.us-east-2.amazonaws.com/dev/dynamodb/users/55";
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
Getting below exception when I call API using above java/spring code.
Exception in thread "main" org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://xyz.execute-api.us-east-1.amazonaws.com/dev/dynamodb/users/55": Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect; nested exception is org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:743)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:669)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:310)
at com.adp.taxcredits.connector.icims.services.CachingServiceImpl.main(CachingServiceImpl.java:46)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to xyz.execute-api.us-east-1.amazonaws.com:443 [xyz.execute-api.us-east-1.amazonaws.com/11.11.232.11, xyz.execute-api.us-east-1.amazonaws.com/52.200.98.93, xyz.execute-api.us-east-1.amazonaws.com/11.81.200.210] failed: Connection timed out: connect
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:87)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:734)
... 3 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 16 more
java amazon-web-services aws-api-gateway resttemplate
java amazon-web-services aws-api-gateway resttemplate
asked Mar 27 at 21:21
Narendra VermaNarendra Verma
1,2764 gold badges22 silver badges53 bronze badges
1,2764 gold badges22 silver badges53 bronze badges
As a test can you try using theOkHttp3ClientHttpRequestFactory
?
– Darren Forsythe
Mar 27 at 22:30
add a comment |
As a test can you try using theOkHttp3ClientHttpRequestFactory
?
– Darren Forsythe
Mar 27 at 22:30
As a test can you try using the
OkHttp3ClientHttpRequestFactory
?– Darren Forsythe
Mar 27 at 22:30
As a test can you try using the
OkHttp3ClientHttpRequestFactory
?– Darren Forsythe
Mar 27 at 22:30
add a comment |
1 Answer
1
active
oldest
votes
Finally, I got this working with below code.
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
public class RestTemplateUtil
public static RestTemplate restTemplate;
public static RestTemplate getRestTemplate()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException
if(restTemplate != null)
return restTemplate;
TrustStrategy acceptingTrustStrategy = new TrustStrategy()
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
return true;
;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
HttpClientBuilder builder = HttpClients.custom();
builder.setSSLSocketFactory(csf);
builder.setProxy(new HttpHost("youproxy.com", 8080, "http"));
CloseableHttpClient httpClient = builder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
restTemplate = new RestTemplate(requestFactory);
return restTemplate;
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386643%2faws-api-gateway-connection-timeout-on-accessing-api-using-spring-resttemplate%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Finally, I got this working with below code.
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
public class RestTemplateUtil
public static RestTemplate restTemplate;
public static RestTemplate getRestTemplate()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException
if(restTemplate != null)
return restTemplate;
TrustStrategy acceptingTrustStrategy = new TrustStrategy()
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
return true;
;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
HttpClientBuilder builder = HttpClients.custom();
builder.setSSLSocketFactory(csf);
builder.setProxy(new HttpHost("youproxy.com", 8080, "http"));
CloseableHttpClient httpClient = builder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
restTemplate = new RestTemplate(requestFactory);
return restTemplate;
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
add a comment |
Finally, I got this working with below code.
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
public class RestTemplateUtil
public static RestTemplate restTemplate;
public static RestTemplate getRestTemplate()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException
if(restTemplate != null)
return restTemplate;
TrustStrategy acceptingTrustStrategy = new TrustStrategy()
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
return true;
;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
HttpClientBuilder builder = HttpClients.custom();
builder.setSSLSocketFactory(csf);
builder.setProxy(new HttpHost("youproxy.com", 8080, "http"));
CloseableHttpClient httpClient = builder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
restTemplate = new RestTemplate(requestFactory);
return restTemplate;
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
add a comment |
Finally, I got this working with below code.
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
public class RestTemplateUtil
public static RestTemplate restTemplate;
public static RestTemplate getRestTemplate()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException
if(restTemplate != null)
return restTemplate;
TrustStrategy acceptingTrustStrategy = new TrustStrategy()
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
return true;
;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
HttpClientBuilder builder = HttpClients.custom();
builder.setSSLSocketFactory(csf);
builder.setProxy(new HttpHost("youproxy.com", 8080, "http"));
CloseableHttpClient httpClient = builder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
restTemplate = new RestTemplate(requestFactory);
return restTemplate;
Finally, I got this working with below code.
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpHost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.HttpClients;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
public class RestTemplateUtil
public static RestTemplate restTemplate;
public static RestTemplate getRestTemplate()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException
if(restTemplate != null)
return restTemplate;
TrustStrategy acceptingTrustStrategy = new TrustStrategy()
@Override
public boolean isTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException
return true;
;
SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy)
.build();
SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());
HttpClientBuilder builder = HttpClients.custom();
builder.setSSLSocketFactory(csf);
builder.setProxy(new HttpHost("youproxy.com", 8080, "http"));
CloseableHttpClient httpClient = builder.build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(httpClient);
restTemplate = new RestTemplate(requestFactory);
return restTemplate;
answered Mar 29 at 18:08
Narendra VermaNarendra Verma
1,2764 gold badges22 silver badges53 bronze badges
1,2764 gold badges22 silver badges53 bronze badges
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
add a comment |
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
Can you explain what exactly is "fixing" the issue?
– Christian Fries
Jun 8 at 10:14
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55386643%2faws-api-gateway-connection-timeout-on-accessing-api-using-spring-resttemplate%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
As a test can you try using the
OkHttp3ClientHttpRequestFactory
?– Darren Forsythe
Mar 27 at 22:30