3

I have a Java based service that is throwing an unexpected SSL exception "Socket is closed"... or sometimes "Data is recieved in a non-data state" when I run it. When I configure a remote debugger by adding jvmArgs: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5050 , and then run it it never throws this exception. Is there something about this option that modifies the behaviour of the service?

Exception:

javax.net.ssl.SSLProtocolException: Data received in non-data state: 6
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1061)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:884)
    at sun.security.ssl.AppInputStream.read(AppInputStream.java:102)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:149)
    at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:110)
    at org.apache.http.impl.io.AbstractSessionInputBuffer.read(AbstractSessionInputBuffer.java:191)
    at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:164)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:138)
    at java.security.DigestInputStream.read(DigestInputStream.java:161)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at com.amazonaws.services.s3.internal.ChecksumValidatingInputStream.read(ChecksumValidatingInputStream.java:97)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at javax.crypto.CipherInputStream.getMoreData(CipherInputStream.java:103)
    at javax.crypto.CipherInputStream.read(CipherInputStream.java:224)
    at java.io.FilterInputStream.read(FilterInputStream.java:133)
    at java.io.FilterInputStream.read(FilterInputStream.java:107)
    at <mypackagenameremovedforanonymity>.GetObjectActivity.enact(GetObjectActivity.java:118)

Context: I am reading from an InputStream that wraps the SSL socket

Bug Killer
  • 661
  • 7
  • 22
  • I've seen this sort of works under the debugger behavior with timing issues. Is this a multi-threaded program? – EGHM Aug 01 '13 at 02:25
  • Yes. I didn't even attach a debugger. Maybe that options inserts something after every statement that checks for a breakpoint or something? I really need to reproduce the error and debug it and would appreciate suggestions – Bug Killer Aug 01 '13 at 02:40

3 Answers3

4

This may be an issue that others have seen with the AWS SDK and Garbage Collection. I had the same kind of issue. Reading from S3 input streams would fail with various socket/SSL errors and when I tried to isolate or debug it, the problem would go away. Turns out the the S3 client connection was getting garbage collected because the input stream was not holding on to it. I found the following link and it solved my problem.

https://forums.aws.amazon.com/thread.jspa?messageID=438171

Rick

P.S. Just to be clear, the above link is for running on the Android, but the problem and solution are generic across all platforms (I ran into it on JDK 7 running on Windows).

Dr Rick
  • 56
  • 2
0

If you are running your application in linux, try this:

  • run your app and after check the program call using 'ps -aux | grep java'
  • run in debug mode and after check the program call using 'ps -aux | grep java'
  • this will make you sure about the jvm path

Another very important thing is checking your system properties by adding the following code to your app:

System.getProperties().list(System.out);
  • after that, compare the output running your app normally and in debug mode.
Danilo Muñoz
  • 623
  • 1
  • 7
  • 17
0

When the error, Data received in non-data state is thrown, check whether the outputstream of socket is closed but the input stream is not closed and continuing to send/receive data and socket is also not closed. Closing the streams of socket along with socket at the end could help to resolve the issue.

AVA
  • 2,474
  • 2
  • 26
  • 41