This is a strange one. I have a Runnable tasked with sending a message to a socket and retrieving the response. When I create a test class that simply creates an instance of the Runnable, sends the message and gets the response, I get the expected output (a CSV String). However, when I run the exact same code as part of the application I'm building, the response is a slew of non-printable characters, starting with "\u0015" (NAK
).1 The protocol that uses sockets doesn't issue NAK
at any point. (It should issue "FAIL_{reason}"
.
Is the fact that I'm getting NAK
in any way something to do with the Java implementation of Socket
itself? (I've tried to get the stack trace for calls, but all I get is up to the point where the run()
method is invoked, without the methods called from within it. As far as I'm aware, at no point between reading from the Socket's Stream and the application asking for a response, via a wrapper, does the character for NAK
get prepended to the response.)
Edit: Having spoken to a more-knowledgeable colleague about the unexpected response, he seems to feel that the application making the socket server is responding with those bytes. However, nothing in its code appears to explicitly make it do so, given that it should respond with human-readable text.
- Specifically, the bytes that I get back are
0x15 0x03 0x01 0x00 0x02 0x02
, which correspond toNAK ETX NUL STX STX
, which is gibberish.