Search in sources :

Example 1 with UnknownResponseReceivedEvent

use of com.couchbase.client.core.cnc.events.io.UnknownResponseReceivedEvent in project couchbase-jvm-clients by couchbase.

the class KeyValueMessageHandler method handleUnknownResponseReceived.

/**
 * Helper method to perform some debug and cleanup logic if a response is received which we didn't expect.
 *
 * @param ctx the channel handler context from netty.
 * @param response the response to decode and handle.
 */
private void handleUnknownResponseReceived(final ChannelHandlerContext ctx, final ByteBuf response) {
    byte[] packet = ByteBufUtil.getBytes(response);
    ioContext.environment().eventBus().publish(new UnknownResponseReceivedEvent(ioContext, packet));
    // We got a response with an opaque value that we know nothing about. There is clearly something weird
    // going on so to be sure we close the connection to avoid any further weird situations.
    closeChannelWithReason(ioContext, ctx, ChannelClosedProactivelyEvent.Reason.KV_RESPONSE_CONTAINED_UNKNOWN_OPAQUE);
}
Also used : UnknownResponseReceivedEvent(com.couchbase.client.core.cnc.events.io.UnknownResponseReceivedEvent)

Aggregations

UnknownResponseReceivedEvent (com.couchbase.client.core.cnc.events.io.UnknownResponseReceivedEvent)1