We are using Spring integration 4.1.3.
Implemented the client using tcp-outbound-gateway.
A tcp rset packet was received from the server during the request and an exception occurred. What is the reason? Thank you.
// interface
public interface TcpSendGateway {
public byte[] send(String text);
}
// send
byte[] response = sendGateway.send(request);
<int:gateway id="gw"
service-interface="com.mainpay.service.TcpSendGateway"
default-request-channel="input"
default-reply-channel="reply"/>
<int-tcp:tcp-connection-factory id="client"
type="client"
host="#{prop['app.cultureland.host']}"
port="#{prop['app.cultureland.port']}"
so-timeout="10000"
single-use="false"
so-keep-alive="true"
/>
<int:channel id="input" />
<int-tcp:tcp-outbound-gateway id="outGateway"
request-channel="input"
reply-channel="reply"
connection-factory="client"
request-timeout="10000"
reply-timeout="10000"
/>
<int:channel id="reply" datatype="java.lang.String" />
ERROR LOG
▶ 17.09.29 17:07:37 [pool-2-thread-2] ERROR o.s.i.i.t.c.TcpNetConnection - Read exception 211.59.10.133:7611:51503:d2ec0199-fd15-49c0-bd99-0d864eb2145b SocketException:Connection reset
▶ 17.09.29 17:07:39 [http-nio-19900-exec-5] ERROR o.s.i.ip.tcp.TcpOutboundGateway - Tcp Gateway exception
org.springframework.messaging.MessagingException: Exception while awaiting reply; nested exception is java.net.SocketException: Connection reset
at org.springframework.integration.ip.tcp.TcpOutboundGateway$AsyncReply.getReply(TcpOutboundGateway.java:288)
wireshark log enter image description here
I think you should be sure that your client and server are agreed with the (de)serialization protocol. See Reference Manual for more info:
TCP is a streaming protocol; this means that some structure has to be provided to data transported over TCP, so the receiver can demarcate the data into discrete messages. Connection factories are configured to use (de)serializers to convert between the message payload and the bits that are sent over TCP.
The default one is the ByteArrayCrLfSerializer
which deals with the \r\n
message delimiter.
So, your client may receive the package but since it doesn't meet the proper delimiter it fails waiting for the reply.