Added gracefull handling when client cut TCP connection

This commit is contained in:
andsel
2017-01-04 11:13:58 +01:00
parent 4029ddd2b1
commit 2c43c74fe3
@@ -28,6 +28,8 @@ import io.netty.handler.codec.CorruptedFrameException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
/**
*
* @author andrea
@@ -100,6 +102,8 @@ public class NettyMQTTHandler extends ChannelInboundHandlerAdapter {
if (cause instanceof CorruptedFrameException) {
//something goes bad with decoding
LOG.warn("Error decoding a packet, probably a bad formatted packet, message: " + cause.getMessage());
} else if (cause instanceof IOException && "Connection reset by peer".equals(cause.getMessage())) {
LOG.warn("Network connection closed abruptly");
} else {
LOG.error("Ugly error on networking", cause);
}