Spring Integration TCP/IP 连接延迟

3
我们正在使用Spring integration 4.1.3。
有时从特定服务器请求连接需要超过5秒钟的时间。
在step1和step2之间发生了什么?
为什么会延迟?
客户端日志:
step1 :▶ DEBUG 11.28 18:14:33.237  [ajp-bio-8109-exec-3] org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory[obtainNewConnection:98] - Opening new socket connection to 10.0.12.111:36401
step2 :▶ DEBUG 11.28 18:14:38.306  [ajp-bio-8109-exec-3] org.springframework.integration.ip.tcp.connection.TcpNetConnection[<init>:138] - New connection 10.0.12.111:36401:2701:561f3524-c421-45ba-9ea5-76a7ddf96430

客户端配置

<int:gateway id="gw-vacct-tcp-sender"
             service-interface="com.mainpay.pay.service.TcpSendVacctGateway"
             default-request-channel="vacct-input"
             default-reply-channel="vacct-reply"
             />

<int-tcp:tcp-connection-factory id="vacct-client"
                                type="client"
                                host="#{springSetting['pay.pg.ngin.vip']}"
                                port="#{springSetting['pay.pg.ngin.vacct.port']}"
                                serializer="TCPJsonSerializer8"
                                deserializer="TCPJsonDeserializer8"
                                single-use="true" 
                                so-timeout="20000"      

/>      

<int:channel id="vacct-input" />

<int-tcp:tcp-outbound-gateway id="vacct-outGateway" 
                              request-channel="vacct-input"
                              reply-channel="vacct-reply" 
                              connection-factory="vacct-client"  
                              reply-timeout="20000"
                              />

<int:channel id="vacct-reply" datatype="java.lang.String" />

这是一个测试服务器,而且是免费的。 - Mr Cho
1个回答

4

尝试将lookup-host设置为false;可能是网络中出现了反向主机查找问题。由于连接ID中使用的是IP地址,因此似乎查找失败。

10.0.12.111:36401:2701:561f3524-c421-45ba-9ea5-76a7ddf96430

请参阅文档

默认情况下,对于入站数据包,会执行反向DNS查找以将IP地址转换为主机名,以便在消息头中使用。在未配置DNS的环境中,这可能会导致连接延迟。您可以通过将lookup-host属性设置为false来覆盖此默认行为。


连接延迟问题不再出现。非常感谢。 - Mr Cho

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接