【问题标题】:Is a TCP inbound gateway automatically closed by Spring?Spring会自动关闭TCP入站网关吗?
【发布时间】:2014-04-13 11:49:01
【问题描述】:

我正在使用 Spring tcp-inbound-gateway 在服务器端侦听 Socket 连接。

我想知道在响应结束返回客户端后是否会自动关闭套接字连接?我在春季文档中找不到任何关于此的内容:http://docs.spring.io/spring-integration/reference/htmlsingle/#ip-endpoint-reference

<ip:tcp-inbound-gateway id="gateway"
    connection-factory="factory"
    request-channel="channel" />

另一个问题:如何指定套接字连接应保持活动的超时?如果在此时间间隔内没有将响应发送回客户端,则关闭套接字?

【问题讨论】:

    标签: java spring sockets tcp spring-integration


    【解决方案1】:

    ConnectionFactory上设置single-use="true",发送回复后会关闭socket。

    使用so-timeout 设置超时套接字选项,套接字将在不活动后关闭。另请参阅入站网关上的reply-timeout

    查看configuration section of the reference manual 了解所有属性及其含义。

    【讨论】:

    • 另见网关上的reply-timeout
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多