0

I am intermittently getting the below error when calling a soap post webservice via https, I have already imported the webservice's cert in my cacert, any idea what is causing this?

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)
mel3kings
  • 8,857
  • 3
  • 60
  • 68
  • It seems there is a connection problem, try run a ping tool and monitor the connection stability between your application server and remote server. – Radi Aug 20 '15 at 06:04
  • @Radi so this has nothing to do with ssl? any tools you can recommend? – mel3kings Aug 20 '15 at 06:06
  • Check this question: http://stackoverflow.com/questions/6772215/java-net-socketexception-software-caused-connection-abort-recv-failed-with-ja – Ravindra babu Aug 20 '15 at 06:09
  • you can use your system builtin command ,For windows :https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sag_tcpip_pro_ping.mspx?mfr=true .For Linux: http://linux.die.net/man/8/ping – Radi Aug 20 '15 at 06:10

2 Answers2

1

This usually means that there was a network error, such as a TCP timeout. I would start by placing a sniffer (wireshark) on the connection to see if you can see any problems. If there is a TCP error, you should be able to see it. Also, you can check your router logs, if this is applicable. If wireless is involved anywhere, that is another source for these kind of errors.

First Link

Second Link

Community
  • 1
  • 1
Yilmaz
  • 41
  • 7
0

Learned that issue was regarding the spring security, generation of nonce and needs to be encoded as Base64

Note that the String, "nonceStr" is not encoded as Base64. But when you put it into the ByteBuffer, "buf", you have decode it as Base64. This will intermittently cause issue depending on whether if the UUID generated is Base64 compliant.

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 

2 out of 3 runs generated nonceStr with issue based on your current code. The simplest change to fix is to simply Base64 encode your generated nonceStr, instead of

String nonceStr = UUID.create(); 

change it to

String nonceStr = new String(Base64.encodeBase64(UUID.create().getBytes())); 
user207421
  • 305,947
  • 44
  • 307
  • 483
mel3kings
  • 8,857
  • 3
  • 60
  • 68