@Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        // If the server requires SSL/TLS, then it will simply shut down the connection if it doesn't get the right
        // handshake. This happens after the TCP connection has already been created. If no packets were received from
        // the server and the connection closes after an HTTP request was sent, then there is a good chance that this is
        // because the server expected a SSL/TLS handshake.
        if ((null == ctx.channel().attr(BYTES_READ).get()) && (null != ctx.channel().attr(REQUEST_SENT).get())) {
            // BYTES_READ is set by the HttpGremlinResponseStreamDecoder when any data is received. If it isn't set,
            // it can be assumed that no bytes were received when the connection closed.
            String errMsg;
            if (ctx.channel().hasAttr(IdleConnectionHandler.IDLE_STATE_EVENT)) {
                errMsg = "Idle timeout occurred before response could be received from server - consider increasing idleConnectionTimeout";
            } else {
                errMsg = "Connection to server closed unexpectedly. Ensure that the server is still" +
                        " reachable. The server may be expecting SSL to be enabled.";
            }
            ctx.fireExceptionCaught(new RuntimeException(errMsg));
        } else {
            super.channelInactive(ctx);
        }
    }
Handler used to detect if the channel has become inactive and throw an error in certain scenarios.
gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/handler/InactiveChannelHandler.java