java - How does the Netty server detect that the client network is abnormally disconnected? ?
PHP中文网
PHP中文网 2017-05-17 10:00:58
0
2
997

The client is javaswing netty, and the server uses Springnetty.
When the server does not use heartbeat detection, if the client suddenly unplugs the network cable and disconnects from the network (note that this is not a client program shutdown, but only an abnormal network disconnection), the server-side Handler
@Override

public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    cause.printStackTrace();
    ctx.close(); //
}

The method did not receive the exception information, so how to detect this? ?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
黄舟

This tcp layer can no longer be sensed. Since the server has no heartbeat, it can only be sensed the next time there is data interaction

黄舟

Without heartbeat detection, if you want to sense data regularly, you can only wait for the next data interaction to sense it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!