Spring 整合 SocketException:Connection 重置
Spring integration SocketException:Connection reset
我的服务器代码:
我的客户代码:https://alvinalexander.com/blog/post/java/simple-java-socket-client-class-program
当我 运行 客户端时,我得到服务器日志: o.s.i.i.tcp.connection.TcpNetConnection : Read exception 127.0.0.1 SocketException:Connection reset
当我使用以下工具对其进行测试时:https://sourceforge.net/projects/sockettest/ 然后服务器可以正常使用 sockettest 应用程序,我认为这是一个客户端问题。
我该如何解决?
org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
使用 ByteArrayCrLfSerializer
反序列化客户端请求:
/**
* 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 {
您应该确定您的客户端确实发送了以 \r\n
结尾的消息。根据示例,它不是:
writeToAndReadFromSocket(socket, "GET /\n\n");
我的服务器代码:
我的客户代码:https://alvinalexander.com/blog/post/java/simple-java-socket-client-class-program
当我 运行 客户端时,我得到服务器日志: o.s.i.i.tcp.connection.TcpNetConnection : Read exception 127.0.0.1 SocketException:Connection reset
当我使用以下工具对其进行测试时:https://sourceforge.net/projects/sockettest/ 然后服务器可以正常使用 sockettest 应用程序,我认为这是一个客户端问题。
我该如何解决?
org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory
使用 ByteArrayCrLfSerializer
反序列化客户端请求:
/**
* 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 {
您应该确定您的客户端确实发送了以 \r\n
结尾的消息。根据示例,它不是:
writeToAndReadFromSocket(socket, "GET /\n\n");