What does 'IllegalStateException [unexpected byte' error on transport client denotes?

I am trying to upgrade elasticsearch from 2.3.1. I have a custom search plugin which I have rewritten.

I have installed the plugin in elasticsearch and all my queries are running fine with the node client (for testing). But whenever I am trying to use the transport client it is throwing the below error on the client side.

Caused by: RemoteTransportException[[_V1H0-K][10.79.69.187:9300][indices:data/read/search]]; nested: IllegalStateException[unexpected byte [0x27]];
Caused by: java.lang.IllegalStateException: unexpected byte [0x27]
        at org.elasticsearch.common.io.stream.StreamInput.readBoolean(StreamInput.java:409)
        at org.elasticsearch.common.io.stream.StreamInput.readBoolean(StreamInput.java:399)
        at org.elasticsearch.common.io.stream.StreamInput.readOptionalWriteable(StreamInput.java:710)
        at org.elasticsearch.search.builder.SearchSourceBuilder.<init>(SearchSourceBuilder.java:189)
        at org.elasticsearch.common.io.stream.StreamInput.readOptionalWriteable(StreamInput.java:711)
        at org.elasticsearch.action.search.SearchRequest.readFrom(SearchRequest.java:397)
        at org.elasticsearch.transport.TcpTransport.handleRequest(TcpTransport.java:1510)
        at org.elasticsearch.transport.TcpTransport.messageReceived(TcpTransport.java:1396)
        at org.elasticsearch.transport.netty4.Netty4MessageChannelHandler.channelRead(Netty4MessageChannelHandler.java:75)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
        at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
        at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:241)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:134)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:644)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:544)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
        at java.lang.Thread.run(Thread.java:748)

I have instantiated by transport client like below

TransportClient transportClient = new PreBuiltTransportClient(settingsBuilder.build(), DocIdDedupPlugin.class);

My plugin code looks like below

public class DocIdDedupPlugin extends Plugin implements SearchPlugin {
    
    @Override
    public ArrayList<AggregationSpec> getAggregations() {
        final ArrayList<SearchPlugin.AggregationSpec> r = new ArrayList<>();

        r.add(new AggregationSpec(
                DocIdDedupBuilder.NAME,
                DocIdDedupBuilder::new,
                DocIdDedupBuilder::parse).addResultReader(InternalDocIdDedup::new)
        );

        r.add(new AggregationSpec(
                SingleBucketDocIdDedupBuilder.NAME,
                SingleBucketDocIdDedupBuilder::new,
                SingleBucketDocIdDedupBuilder::parse).addResultReader(InternalSingleBucketDocIdDedup::new)
        );
        r.add(new AggregationSpec(
                CollectBuilder.NAME,
                CollectBuilder::new,
                CollectBuilder::parse).addResultReader(InternalCollect::new)
        );
        return r;
    }

    @Override
    public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
        final ArrayList writeables = new ArrayList();
        writeables.add(new NamedWriteableRegistry.Entry(
                DocIdDedupBuilder.class,
                DocIdDedupBuilder.NAME,
                DocIdDedupBuilder::new));

        writeables.add(new NamedWriteableRegistry.Entry(
                SingleBucketDocIdDedupBuilder.class,
                SingleBucketDocIdDedupBuilder.NAME,
                SingleBucketDocIdDedupBuilder::new));

        writeables.add(new NamedWriteableRegistry.Entry(
                CollectBuilder.class,
                CollectBuilder.NAME,
                CollectBuilder::new));
        return writeables;
    }
}

Can someone let me know what does this error on the client-side denote and what am I doing wrong?

I am trying to upgrade to elasticsearch 5.6.16 first.

Anyone any thoughts on this?

The problem was in CollectBuilder the fields that were written to StreamOutput in innerWriteTo was not read in the same order in CollectBuilder(StreamInput input) constructor.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.