My server code: https://stackoverflow.com/a/41765722/3871754
My client code: https://alvinalexander.com/blog/post/java/simple-java-socket-client-class-program
When I run the client, I get on server logs: o.s.i.i.tcp.connection.TcpNetConnection : Read exception 127.0.0.1 SocketException:Connection reset
When I tested it with the tool: https://sourceforge.net/projects/sockettest/ then server works properly with sockettest app, I think this is a client issue.
How can I fix it?
The org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
uses ByteArrayCrLfSerializer
to deserialize client requests:
/**
* Reads data in an InputStream to a byte[]; data must be terminated by \r\n
* (not included in resulting byte[]).
* Writes a byte[] to an OutputStream and adds \r\n.
*
* @author Gary Russell
* @since 2.0
*/
public class ByteArrayCrLfSerializer extends AbstractPooledBufferByteArraySerializer {
You should be sure that your client really sends messages terminated with the \r\n
. According to the sample it's not:
writeToAndReadFromSocket(socket, "GET /\n\n");