RestTemplate configuration code is as follows
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(30000);
httpRequestFactory.setConnectTimeout(30000);
httpRequestFactory.setReadTimeout(30000);
return builder.requestFactory(() -> httpRequestFactory).build();
}
the error message is as follows:
org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest": Connect to pro-api.coinmarketcap.com:443 [pro-api.coinmarketcap.com/13.35.121.116, pro-api.coinmarketcap.com/13.35.121.31, pro-api.coinmarketcap.com/13.35.121.107] failed: Read timed out; nested exception is org.apache.http.conn.ConnectTimeoutException: Connect to pro-api.coinmarketcap.com:443 [pro-api.coinmarketcap.com/13.35.121.116, pro-api.coinmarketcap.com/13.35.121.31, pro-api.coinmarketcap.com/13.35.121.107] failed: Read timed out
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:696)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:622)
at com.chinawkb.monitor.service.impl.CoinMarketServiceImpl.getData(CoinMarketServiceImpl.java:58)
at com.chinawkb.monitor.service.impl.CoinMarketServiceImpl.updateTokenInfos(CoinMarketServiceImpl.java:39)
at com.chinawkb.monitor.EthereumMonitorApplication$Test.run(EthereumMonitorApplication.java:59)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:792)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)
at com.chinawkb.monitor.EthereumMonitorApplication.main(EthereumMonitorApplication.java:38)
Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to pro-api.coinmarketcap.com:443 [pro-api.coinmarketcap.com/13.35.121.116, pro-api.coinmarketcap.com/13.35.121.31, pro-api.coinmarketcap.com/13.35.121.107] failed: Read timed out
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
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:687)
... 10 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:355)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 23 common frames omitted
confirmed that the rest interface is accessible (postMan on the same machine can work properly)
has anyone ever met, ask for advice!