search

Home  >  Q&A  >  body text

java - How does the Netty server detect that the client network is abnormally disconnected? ?

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中文网2775 days ago1076

reply all(2)I'll reply

  • 黄舟

    黄舟2017-05-17 10:02:58

    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

    reply
    0
  • 黄舟

    黄舟2017-05-17 10:02:58

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

    reply
    0
  • Cancelreply