简体   繁体   English

在resttemplate.exchange上的SocketException连接重置错误

[英]SocketException Connection Reset error on resttemplate.exchange

I started to get ConnectionReset error when i try make request to an apple api url. 当我尝试向苹果api url发出请求时,我开始出现ConnectionReset错误。

I made no code change but it suddenly started to give errors. 我没有进行代码更改,但突然开始出现错误。 When i call the url with curl command i can get answer but when i call it from the code it throws the below exception. 当我使用curl命令调用url时,我可以得到答案,但是当我从代码中调用它时,它将引发以下异常。

What might be causing this error? 是什么导致此错误?

Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://api-applecareconnect.apple.com/enroll-service/1.0/show-order-details": Connection reset; nested exception is java.net.SocketException: Connection reset
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:534)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:482)
    at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:430)


Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:210)
    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:394)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    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:55)
    at org.springframework.http.client.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:82)
    at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
    at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:50)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:519)
    ... 122 more

Please see my answer here I/O error on POST request for... java.net.SocketException: Connection reset 请在此处查看我的答案POST请求的I / O错误... java.net.SocketException:连接重置

This seems to be the same problem. 这似乎是相同的问题。 @EspringDev is actually pointing the right direction. @EspringDev实际上指向正确的方向。 As per apple , they support all the versions through 1.0 to 1.3. 按照Apple的规定,它们支持从1.0到1.3的所有版本。 But the API you consume could have a SSL/TLS security policy . 但是您使用的API可能具有SSL / TLS安全策略 I hope this will solve the issue. 我希望这可以解决问题。

It turns out the problem was a firewall policy changed without our information. 事实证明,问题出在没有我们的信息的情况下更改了防火墙策略。 It blocked the access to apple servers. 它阻止了对Apple服务器的访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM