我在通过https调用soap post webservice时间歇地得到以下错误,我已经在我的cacert中导入了webservice的证书,不知道是什么导致了这个?
Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:150)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
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:954)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:911)
答案 0 :(得分:1)
这通常意味着存在网络错误,例如TCP超时。我首先在连接上放置一个嗅探器(wireshark),看看你是否能看到任何问题。如果存在TCP错误,您应该能够看到它。此外,如果适用,您可以检查路由器日志。如果在任何地方都涉及无线,那么这就是造成这类错误的另一个原因。
答案 1 :(得分:0)
据悉该问题涉及Spring安全性,nonce的生成以及需要编码为Base64
请注意,字符串“nonceStr”未编码为Base64。但是当你把它放入ByteBuffer,“buf”时,你就把它解码为Base64。这将间歇性地导致问题,具体取决于生成的UUID是否符合Base64。
String nonceStr = UUID.create();
System.out.println("nonceStr: "+nonceStr);
byte[] a = Base64.decodeBase64(nonceStr.getBytes());
System.out.println("nonceStr: "+Base64.encodeBase64String(a));
String base64NonceStr = new String(Base64.encodeBase64(nonceStr.getBytes()));
System.out.println("base64NonceStr: "+base64NonceStr);
byte[] b = Base64.decodeBase64(base64NonceStr.getBytes());
System.out.println("base64NonceStr: "+Base64.encodeBase64String(b));
nonceStr: ac1c6f1cc80f4cbde9f753bfd5f0fa
nonceStr: ac1c6f1cc80f4cbde9f753bfd5f0fQ==
base64NonceStr: YWMxYzZmMWNjODBmNGNiZGU5Zjc1M2JmZDVmMGZh
base64NonceStr: YWMxYzZmMWNjODBmNGNiZGU5Zjc1M2JmZDVmMGZh
nonceStr: ac1c6f1c2da679b7dea1384b81fb2431
nonceStr: ac1c6f1c2da679b7dea1384b81fb2431
base64NonceStr: YWMxYzZmMWMyZGE2NzliN2RlYTEzODRiODFmYjI0MzE=
base64NonceStr: YWMxYzZmMWMyZGE2NzliN2RlYTEzODRiODFmYjI0MzE=
nonceStr: ac1c6f1cc80f4cbdea17677b796ad8
nonceStr: ac1c6f1cc80f4cbdea17677b796adw==
base64NonceStr: YWMxYzZmMWNjODBmNGNiZGVhMTc2NzdiNzk2YWQ4
base64NonceStr: YWMxYzZmMWNjODBmNGNiZGVhMTc2NzdiNzk2YWQ4
3次运行中有2次根据您当前的代码生成了nonceStr问题。最简单的修改方法是简单地对生成的nonceStr进行Base64编码,而不是
String nonceStr = UUID.create();
将其更改为
String nonceStr = new String(Base64.encodeBase64(UUID.create().getBytes()));