Spring Integration TCP-什么是完​​全关闭监听套接字的好方法

时间:2018-08-13 13:34:42

标签: sockets spring-integration tcpclient file-descriptor

使用它是否是个好选择

AbstractServerConnectionFactory.closeCOnnection(ClientConnId)。我正在使用此功能,但是发生的情况是服务器处理几天后开始出现“打开的文件太多” 错误。我通过运行命令“ lsof”和“ / proc / pid / fd”调查了该问题,该命令向我显示了有关套接字和管道的280个文件描述符

*(I have pasted the file descriptor outcome at the end of the question thread)*. 

活动tcp连接数为12 ,但文件描述符的数量远远超过活动连接数和每天增长的数量。

我的应用程序确实打开了12个文件,但是文件的文件描述符计数没有增加,仅为12,这是预期的计数。 我认为罪魁祸首是客户端套接字未正确关闭。

使用的示例代码

AbstractServerConnectionFactory.closeCOnnection(ClientConnId)

AbstractServerConnectionFactory connFactory = (AbstractServerConnectionFactory) applicationContext.getBean("server");
connFactory.closeConnection(clientConnId);

我从Spring TCP消息标题“ IpHeaders.CONNECTION_ID”中获取了客户端连接ID

在我的应用程序中,客户端连接到服务器套接字,并通过客户端建立的TCP连接向服务器套接字发送命令,服务器套接字相应地从文件中回复数据。客户端必须每两秒钟向服务器套接字发送一个文本“有效”。如果未收到此“活动”服务器,则应  断开此客户端连接。对于“信息”,我的应用程序中的TCP服务器套接字大约需要3个tcp客户端连接。如果客户端中的任何一个未能发送“活动”命令,则服务器套接字必须终止该连接。

我已经看到了另一种通过抛出SoftEndOfStreamException 来关闭连接的解决方案。但是此异常似乎关闭了整个服务器套接字。我只想关闭一个客户端连接,而该客户端连接无法发送活动命令。

throw new SoftEndOfStreamException

tcp-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans=...>

    <context:property-placeholder />

    <task:annotation-driven />

    <beans:bean id="stxEtxSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer">
    </beans:bean>

    <beans:bean id="logdistSerializer" class="com.appc.logdist.tcp.socket.logdistSerializerDeSerializer">
    </beans:bean>

    <beans:bean class="com.appc.logdist.tcp.socket.listener.TcpConnCloseEventListener"></beans:bean>
    <beans:bean class="com.appc.logdist.tcp.socket.listener.TcpConnOpenEventListener"></beans:bean>
    <beans:bean class="com.appc.logdist.tcp.socket.listener.TcpConnFailedCorrEventListener"></beans:bean>
    <beans:bean class="com.appc.logdist.tcp.socket.listener.TcpConnSrvrExcepEventListener"></beans:bean>
    <beans:bean class="com.appc.logdist.tcp.socket.listener.TcpConnExcepEventListener"></beans:bean>

    <channel id="toSA"/>
    <channel id="toObAdapter" />
    <channel id="toErrorChannel" />

    <bridge input-channel="toErrorChannel" output-channel="toObAdapter"></bridge>
    <bridge input-channel="inputErrorChannel" output-channel="toObAdapter"></bridge>

<!-- Server side -->

<!-- Connection Factory -->
    <ip:tcp-connection-factory id="server"
        type="server"
        port="${port}"
        using-nio="true"
                serializer="logdistSerializer"
        deserializer="stxEtxSerializer"/>

<!-- Inbound Channel Adapter -->
    <ip:tcp-inbound-channel-adapter id="inAdapter.server"
        channel="toSA"
        connection-factory="server" />

    <beans:bean class="java.lang.String" name="hostId" >
        <beans:constructor-arg value="${hostId}"></beans:constructor-arg>
    </beans:bean>

<!-- Validation Service -->
    <service-activator input-channel="toSA"
                       ref="logdistMessageReceiver"
                       method="validate" />
                       <!-- output-channel="toObAdapter" -->
    <beans:bean id="logdistMessageReceiver"
          class="com.appc.logdist.validation.logdistInputValidator" />


<!-- Outbound Server Flow -->

<!-- Outbound Channel Adapter -->
    <ip:tcp-outbound-channel-adapter id="outAdapter.server"
        channel="toObAdapter"
        connection-factory="server" />

    <beans:bean id="logdistWaiter" class="com.appc.logdist.reader.logdistRequestServer" scope="prototype">
        <beans:property name="logdistLogRedr" ref="logdistLogReader"></beans:property>
    </beans:bean>
    <beans:bean id="logdistLogReader" class="com.appc.logdist.reader.logdistLogReaderImpl" scope="prototype"></beans:bean>

    <task:scheduled-tasks scheduler="logdistPulseScheduler">
        <task:scheduled ref="logdistMessageReceiver" method="generatePulse" fixed-delay="800" initial-delay="2"/>
        <task:scheduled ref="logdistMessageReceiver" method="checkHealthIsReceived" fixed-delay="8000" initial-delay="3"/>
    </task:scheduled-tasks>

    <task:scheduler id="logdistPulseScheduler" pool-size="6"/>

</beans:beans>

文件描述符计数

[root@logdist ~]# lsof -i -p 25871
PID    FD   TYPE             DEVICE SIZE/OFF      NODE NAME
25871  mem    REG              253,0 39470476   1457712 /Data/logdist-app/logdist-core/logdist-core.jar
25871   12u  unix 0xffff8802385b2780      0t0 100031047 socket
25871   13u  IPv4          100031049      0t0       TCP *:36152 (LISTEN)
25871   14u  IPv4          100031050      0t0       TCP *:rmiregistry (LISTEN)
25871   15u  IPv4          100031053      0t0       TCP *:46576 (LISTEN)
25871   17u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   19w   REG              253,0 43443203   1317895 /Data/logdist-app/logs/logdist-2018-08-13.2.log
25871   20u   REG              253,0  2097173   1457274 /Data/logdist-app/logdist-core/transaction-logs/part1.btm
25871   21u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   22u   REG              253,0  2097173   1457273 /Data/logdist-app/logdist-core/transaction-logs/part2.btm
25871   24u  IPv4          100031160      0t0       TCP localhost:45288->localhost:mysql (ESTABLISHED)
25871   25u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   27u  IPv4          100031429      0t0       TCP *:6866 (LISTEN)
25871   28r  FIFO                0,8      0t0 100031430 pipe
25871   29w  FIFO                0,8      0t0 100031430 pipe
25871   30u   REG                0,9        0      3853 [eventpoll]
25871   31u  IPv4          100031431      0t0       TCP *:6867 (LISTEN)
25871   32r  FIFO                0,8      0t0 100031432 pipe
25871   33w  FIFO                0,8      0t0 100031432 pipe
25871   34u   REG                0,9        0      3853 [eventpoll]
25871   35u  IPv4          100031433      0t0       TCP *:acctopus-cc (LISTEN)
25871   36r  FIFO                0,8      0t0 100031434 pipe
25871   37w  FIFO                0,8      0t0 100031434 pipe
25871   38u   REG                0,9        0      3853 [eventpoll]
25871   39u  IPv4          100031435      0t0       TCP 10.12.11.3:6866->192.102.9.50:38978 (ESTABLISHED)
25871   40u  IPv4          100931202      0t0       TCP 10.12.11.3:6867->192.102.9.50:39814 (ESTABLISHED)
25871   41u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   42u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   43u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   44r   REG              253,0   214218   1457301 /Data/logdist-app/prod-files/output/aman/2018-08-13.log
25871   45r   REG              253,0    47921   1457302 /Data/logdist-app/prod-files/output/dflow/2018-08-13.log
25871   46r  FIFO                0,8      0t0 100031446 pipe
25871   47w  FIFO                0,8      0t0 100031446 pipe
25871   48u   REG                0,9        0      3853 [eventpoll]
25871   49u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   50u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   51u  IPv4          102305722      0t0       TCP logdist:6866->192.102.65.42:43056 (ESTABLISHED)
25871   52u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   53u  IPv4          100031459      0t0       TCP 192.102.246.5:6867->192.102.246.2:55232 (ESTABLISHED)
25871   54r   REG              253,0   214218   1457301 /Data/logdist-app/prod-files/output/aman/2018-08-13.log
25871   55u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   56u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   57r  FIFO                0,8      0t0 100031465 pipe
25871   58w  FIFO                0,8      0t0 100031465 pipe
25871   59u   REG                0,9        0      3853 [eventpoll]
25871   60u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   61r  FIFO                0,8      0t0 100031466 pipe
25871   62w  FIFO                0,8      0t0 100031466 pipe
25871   63u   REG                0,9        0      3853 [eventpoll]
25871   64u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   65r  FIFO                0,8      0t0 100411961 pipe
25871   66r   REG              253,0    47921   1457302 /Data/logdist-app/prod-files/output/dflow/2018-08-13.log
25871   67r  FIFO                0,8      0t0 100171486 pipe
25871   70w  FIFO                0,8      0t0 100171486 pipe
25871   71u   REG                0,9        0      3853 [eventpoll]
25871   72w  FIFO                0,8      0t0 100411961 pipe
25871   73u   REG                0,9        0      3853 [eventpoll]
25871   74u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   75r  FIFO                0,8      0t0 100602902 pipe
25871   76w  FIFO                0,8      0t0 100602902 pipe
25871   77u   REG                0,9        0      3853 [eventpoll]
25871   78u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   79r  FIFO                0,8      0t0 100659853 pipe
25871   80w  FIFO                0,8      0t0 100659853 pipe
25871   81u   REG                0,9        0      3853 [eventpoll]
25871   82u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   83r  FIFO                0,8      0t0 100666338 pipe
25871   84w  FIFO                0,8      0t0 100666338 pipe
25871   85u   REG                0,9        0      3853 [eventpoll]
25871   86r  FIFO                0,8      0t0 100680384 pipe
25871   87r  FIFO                0,8      0t0 100674499 pipe
25871   88w  FIFO                0,8      0t0 100674499 pipe
25871   89u   REG                0,9        0      3853 [eventpoll]
25871   90w  FIFO                0,8      0t0 100680384 pipe
25871   91u   REG                0,9        0      3853 [eventpoll]
25871   92u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   93u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   94u  unix 0xffff88023adb8840      0t0 100031061 socket
25871   95r  FIFO                0,8      0t0 100680391 pipe
25871   96w  FIFO                0,8      0t0 100680391 pipe
25871   97u   REG                0,9        0      3853 [eventpoll]
25871   98r  FIFO                0,8      0t0 100680577 pipe
25871   99r  FIFO                0,8      0t0 100680392 pipe
25871  100w  FIFO                0,8      0t0 100680392 pipe
25871  101u   REG                0,9        0      3853 [eventpoll]
25871  102w  FIFO                0,8      0t0 100680577 pipe
25871  103u   REG                0,9        0      3853 [eventpoll]
25871  104u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  105u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  106r  FIFO                0,8      0t0 100680606 pipe
25871  107w  FIFO                0,8      0t0 100680606 pipe
25871  108u   REG                0,9        0      3853 [eventpoll]
25871  109u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  110r  FIFO                0,8      0t0 100680607 pipe
25871  111w  FIFO                0,8      0t0 100680607 pipe
25871  112u   REG                0,9        0      3853 [eventpoll]
25871  113r  FIFO                0,8      0t0 100680615 pipe
25871  114w  FIFO                0,8      0t0 100680615 pipe
25871  115u   REG                0,9        0      3853 [eventpoll]
25871  116u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  117u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  118r  FIFO                0,8      0t0 100680716 pipe
25871  119w  FIFO                0,8      0t0 100680716 pipe
25871  120u   REG                0,9        0      3853 [eventpoll]
25871  121u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  122u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  123u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  124r  FIFO                0,8      0t0 100680829 pipe
25871  125w  FIFO                0,8      0t0 100680829 pipe
25871  126u   REG                0,9        0      3853 [eventpoll]
25871  127u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  128r  FIFO                0,8      0t0 100680900 pipe
25871  129w  FIFO                0,8      0t0 100680900 pipe
25871  130u   REG                0,9        0      3853 [eventpoll]
25871  131u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  132r  FIFO                0,8      0t0 100681039 pipe
25871  133w  FIFO                0,8      0t0 100681039 pipe
25871  134u   REG                0,9        0      3853 [eventpoll]
25871  135r  FIFO                0,8      0t0 100681249 pipe
25871  136r  FIFO                0,8      0t0 100681141 pipe
25871  137w  FIFO                0,8      0t0 100681141 pipe
25871  138u   REG                0,9        0      3853 [eventpoll]
25871  139w  FIFO                0,8      0t0 100681249 pipe
25871  140u   REG                0,9        0      3853 [eventpoll]
25871  141u  IPv4          102309329      0t0       TCP logdist:6867->192.102.65.43:42326 (ESTABLISHED)
25871  142r  IPv4          102304207      0t0       TCP 192.102.246.5:6866->192.102.246.1:44626 (ESTABLISHED)
25871  143u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  144r  FIFO                0,8      0t0 100681458 pipe
25871  145w  FIFO                0,8      0t0 100681458 pipe
25871  146u   REG                0,9        0      3853 [eventpoll]
25871  147u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  148r  FIFO                0,8      0t0 100681463 pipe
25871  149w  FIFO                0,8      0t0 100681463 pipe
25871  150u   REG                0,9        0      3853 [eventpoll]
25871  151r  FIFO                0,8      0t0 100686734 pipe
25871  152r  FIFO                0,8      0t0 100681668 pipe
25871  153w  FIFO                0,8      0t0 100681668 pipe
25871  154u   REG                0,9        0      3853 [eventpoll]
25871  155r  FIFO                0,8      0t0 100683493 pipe
25871  156w  FIFO                0,8      0t0 100683493 pipe
25871  157u   REG                0,9        0      3853 [eventpoll]
25871  158w  FIFO                0,8      0t0 100686734 pipe
25871  159u   REG                0,9        0      3853 [eventpoll]
25871  160u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  161u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  162r  FIFO                0,8      0t0 100686738 pipe
25871  163w  FIFO                0,8      0t0 100686738 pipe
25871  164u   REG                0,9        0      3853 [eventpoll]
25871  165u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  166r  FIFO                0,8      0t0 100686840 pipe
25871  167w  FIFO                0,8      0t0 100686840 pipe
25871  168u   REG                0,9        0      3853 [eventpoll]
25871  169u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  170u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  171r  FIFO                0,8      0t0 100686935 pipe
25871  172w  FIFO                0,8      0t0 100686935 pipe
25871  173u   REG                0,9        0      3853 [eventpoll]
25871  174u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  175r  FIFO                0,8      0t0 100686952 pipe
25871  176w  FIFO                0,8      0t0 100686952 pipe
25871  177u   REG                0,9        0      3853 [eventpoll]
25871  178r  FIFO                0,8      0t0 100687163 pipe
25871  179r  FIFO                0,8      0t0 100687079 pipe
25871  180w  FIFO                0,8      0t0 100687079 pipe
25871  181u   REG                0,9        0      3853 [eventpoll]
25871  182w  FIFO                0,8      0t0 100687163 pipe
25871  183u   REG                0,9        0      3853 [eventpoll]
25871  184u   REG              253,0    47921   1457302 /Data/logdist-app/prod-files/output/dflow/2018-08-13.log
25871  185r   REG              253,0   214218   1457301 /Data/logdist-app/prod-files/output/aman/2018-08-13.log
25871  186r  FIFO                0,8      0t0 101182477 pipe
25871  187r  FIFO                0,8      0t0 101071687 pipe
25871  188w  FIFO                0,8      0t0 101071687 pipe
25871  189u   REG                0,9        0      3853 [eventpoll]
25871  190w  FIFO                0,8      0t0 101182477 pipe
25871  191u   REG                0,9        0      3853 [eventpoll]
25871  192u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  193u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  194u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  195u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  196u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  197r  FIFO                0,8      0t0 101182689 pipe
25871  198w  FIFO                0,8      0t0 101182689 pipe
25871  199u   REG                0,9        0      3853 [eventpoll]
25871  200r  FIFO                0,8      0t0 101194033 pipe
25871  201r  FIFO                0,8      0t0 101182736 pipe
25871  202w  FIFO                0,8      0t0 101182736 pipe
25871  203u   REG                0,9        0      3853 [eventpoll]
25871  204r  FIFO                0,8      0t0 101183098 pipe
25871  205w  FIFO                0,8      0t0 101183098 pipe
25871  206u   REG                0,9        0      3853 [eventpoll]
25871  207r  FIFO                0,8      0t0 101183099 pipe
25871  208w  FIFO                0,8      0t0 101183099 pipe
25871  209u   REG                0,9        0      3853 [eventpoll]
25871  210w  FIFO                0,8      0t0 101194033 pipe
25871  211u   REG                0,9        0      3853 [eventpoll]
25871  212u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  213u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  214r  FIFO                0,8      0t0 101194037 pipe
25871  215w  FIFO                0,8      0t0 101194037 pipe
25871  216u   REG                0,9        0      3853 [eventpoll]
25871  217u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  218u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  219r  FIFO                0,8      0t0 101194041 pipe
25871  220w  FIFO                0,8      0t0 101194041 pipe
25871  221u   REG                0,9        0      3853 [eventpoll]
25871  222u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  223u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  224r  FIFO                0,8      0t0 101194254 pipe
25871  225w  FIFO                0,8      0t0 101194254 pipe
25871  226u   REG                0,9        0      3853 [eventpoll]
25871  227r  unix 0xffff88023adb8840      0t0 100031061 socket
25871  228r  FIFO                0,8      0t0 101194255 pipe
25871  229w  FIFO                0,8      0t0 101194255 pipe
25871  230u   REG                0,9        0      3853 [eventpoll]
25871  231r  FIFO                0,8      0t0 101194356 pipe
25871  232w  FIFO                0,8      0t0 101194356 pipe
25871  233u   REG                0,9        0      3853 [eventpoll]
25871  234u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  235u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  236r  FIFO                0,8      0t0 101194403 pipe
25871  237w  FIFO                0,8      0t0 101194403 pipe
25871  238u   REG                0,9        0      3853 [eventpoll]
25871  239u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  240r  FIFO                0,8      0t0 101194469 pipe
25871  241w  FIFO                0,8      0t0 101194469 pipe
25871  242u   REG                0,9        0      3853 [eventpoll]
25871  243u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  244r  FIFO                0,8      0t0 101194676 pipe
25871  245w  FIFO                0,8      0t0 101194676 pipe
25871  246u   REG                0,9        0      3853 [eventpoll]
25871  247u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  248r  FIFO                0,8      0t0 101194827 pipe
25871  249w  FIFO                0,8      0t0 101194827 pipe
25871  250u   REG                0,9        0      3853 [eventpoll]
25871  251u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  252r  FIFO                0,8      0t0 101194887 pipe
25871  253w  FIFO                0,8      0t0 101194887 pipe
25871  254u   REG                0,9        0      3853 [eventpoll]
25871  255u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  256r  FIFO                0,8      0t0 101195094 pipe
25871  257w  FIFO                0,8      0t0 101195094 pipe
25871  258u   REG                0,9        0      3853 [eventpoll]
25871  259u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  260r  FIFO                0,8      0t0 101195196 pipe
25871  261w  FIFO                0,8      0t0 101195196 pipe
25871  262u   REG                0,9        0      3853 [eventpoll]
25871  263u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  264r  FIFO                0,8      0t0 101195304 pipe
25871  265w  FIFO                0,8      0t0 101195304 pipe
25871  266u   REG                0,9        0      3853 [eventpoll]
25871  267r  FIFO                0,8      0t0 101238507 pipe
25871  268w  FIFO                0,8      0t0 101238507 pipe
25871  269u   REG                0,9        0      3853 [eventpoll]
25871  270u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  271r  FIFO                0,8      0t0 101279569 pipe
25871  272w  FIFO                0,8      0t0 101279569 pipe
25871  273u   REG                0,9        0      3853 [eventpoll]
25871  274r  FIFO                0,8      0t0 101731766 pipe
25871  275r  FIFO                0,8      0t0 101313450 pipe
25871  276w  FIFO                0,8      0t0 101313450 pipe
25871  277u   REG                0,9        0      3853 [eventpoll]
25871  278w  FIFO                0,8      0t0 101731766 pipe
25871  279u   REG                0,9        0      3853 [eventpoll]
25871  280u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  281u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  282u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  283r  FIFO                0,8      0t0 101731773 pipe
25871  284w  FIFO                0,8      0t0 101731773 pipe
25871  285u   REG                0,9        0      3853 [eventpoll]
25871  286u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  287r  FIFO                0,8      0t0 101731774 pipe
25871  288w  FIFO                0,8      0t0 101731774 pipe
25871  289u   REG                0,9        0      3853 [eventpoll]
25871  290u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  291r  FIFO                0,8      0t0 101731983 pipe
25871  292w  FIFO                0,8      0t0 101731983 pipe
25871  293u   REG                0,9        0      3853 [eventpoll]
25871  294r  unix 0xffff88023adb8840      0t0 100031061 socket
25871  295r  FIFO                0,8      0t0 101731984 pipe
25871  296w  FIFO                0,8      0t0 101731984 pipe
25871  297u   REG                0,9        0      3853 [eventpoll]
25871  298u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  299r  FIFO                0,8      0t0 101732085 pipe
25871  300w  FIFO                0,8      0t0 101732085 pipe
25871  301u   REG                0,9        0      3853 [eventpoll]
25871  302r  FIFO                0,8      0t0 102106556 pipe
25871  303r  FIFO                0,8      0t0 101732194 pipe
25871  304w  FIFO                0,8      0t0 101732194 pipe
25871  305u   REG                0,9        0      3853 [eventpoll]
25871  306u  FIFO                0,8      0t0 102106556 pipe
25871  307u  IPv4          102266066      0t0       TCP logdist:rmiregistry->192.102.65.18:50904 (ESTABLISHED)
25871  309u   REG                0,9        0      3853 [eventpoll]
25871  310u  IPv4          102037167      0t0       TCP logdist:rmiregistry->192.102.65.18:51359 (ESTABLISHED)
25871  311u  unix 0xffff88023ad64f00      0t0 102039331 /tmp/.java_pid25871.tmp
25871  313w   REG              253,0    17068   1317908 /root/.yjp/log/logdist-core-25871.log
25871  314r   REG              253,0  1298105   1048616 /tmp/yjp201807311816.jar
25871  315u  IPv4          102039343      0t0       TCP localhost:scp-config (LISTEN)
25871  316u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  317u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  318r  FIFO                0,8      0t0 102106560 pipe
25871  319w  FIFO                0,8      0t0 102106560 pipe
25871  320u   REG                0,9        0      3853 [eventpoll]
25871  321u  IPv4          102106561      0t0       TCP 10.12.11.3:acctopus-cc->192.102.9.52:36330 (ESTABLISHED)
25871  322r   REG              253,0 79421704   1457300 /Data/logdist-app/prod-files/output/sfpl/2018-08-13.log
25871  323u  unix 0xffff88023adb8840      0t0 100031061 socket
25871  324r  FIFO                0,8      0t0 102106779 pipe
25871  325w  FIFO                0,8      0t0 102106779 pipe
25871  326u   REG                0,9        0      3853 [eventpoll]
25871  327u  IPv4          102115534      0t0       TCP 192.102.246.5:acctopus-cc->192.102.246.2:32994 (ESTABLISHED)
25871  328r  FIFO                0,8      0t0 102106861 pipe
25871  329w  FIFO                0,8      0t0 102106861 pipe
25871  330u   REG                0,9        0      3853 [eventpoll]
25871  331r  FIFO                0,8      0t0 102107226 pipe
25871  332w  FIFO                0,8      0t0 102107226 pipe
25871  333u   REG                0,9        0      3853 [eventpoll]
25871  334r  FIFO                0,8      0t0 102115327 pipe
25871  335w  FIFO                0,8      0t0 102115327 pipe
25871  336u   REG                0,9        0      3853 [eventpoll]
25871  337u  IPv4          102115328      0t0       TCP logdist:acctopus-cc->192.102.65.43:36846 (ESTABLISHED)
25871  338r   REG              253,0 79421704   1457300 /Data/logdist-app/prod-files/output/sfpl/2018-08-13.log
25871  339r  FIFO                0,8      0t0 102115331 pipe
25871  340w  FIFO                0,8      0t0 102115331 pipe
25871  341u   REG                0,9        0      3853 [eventpoll]
25871  342r   REG              253,0 79421704   1457300 /Data/logdist-app/prod-files/output/sfpl/2018-08-13.log
25871  343r  FIFO                0,8      0t0 102115537 pipe
25871  344w  FIFO                0,8      0t0 102115537 pipe
25871  345u   REG                0,9        0      3853 [eventpoll]
25871  346u  IPv4          102276973      0t0       TCP logdist:rmiregistry->192.102.65.18:54587 (ESTABLISHED)

1 个答案:

答案 0 :(得分:1)

使用其ID关闭套接字应将其完全关闭。

但是,只需设置soTimeout属性,操作系统就会通知该框架,如果在该时间内没有收到数据,它将关闭套接字。

  

引发新的SoftEndOfStreamException

我不确定您在哪里进行操作,但是我无法想到会关闭服务器套接字的情况。

仅当从反序列化器(当它检测到消息之间的套接字关闭)时才抛出该异常。