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

**URL:** <https://discuss.elastic.co/t/what-does-illegalstateexception-unexpected-byte-error-on-transport-client-denotes/197396>\
**Category:** Elasticsearch\
**Created:** [August 29, 2019, 6:13pm UTC](https://discuss.elastic.co/t/what-does-illegalstateexception-unexpected-byte-error-on-transport-client-denotes/197396 "2019-08-29T18:13:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deb/32/46162_2.png) [@Deb](https://discuss.elastic.co/u/Deb)\
**Post date:** [August 29, 2019, 6:13pm UTC](https://discuss.elastic.co/t/what-does-illegalstateexception-unexpected-byte-error-on-transport-client-denotes/197396/1 "2019-08-29T18:13:17Z")

</div>

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

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

```

My plugin code looks like below

```auto
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.

---

<div class="post-metadata">

**Author:** ![Deb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deb/32/46162_2.png) [@Deb](https://discuss.elastic.co/u/Deb)\
**Post date:** [August 30, 2019, 5:35am UTC](https://discuss.elastic.co/t/what-does-illegalstateexception-unexpected-byte-error-on-transport-client-denotes/197396/2 "2019-08-30T05:35:10Z")

</div>

Anyone any thoughts on this?

---

<div class="post-metadata">

**Author:** ![Deb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/deb/32/46162_2.png) [@Deb](https://discuss.elastic.co/u/Deb)\
**Post date:** [September 3, 2019, 9:55am UTC](https://discuss.elastic.co/t/what-does-illegalstateexception-unexpected-byte-error-on-transport-client-denotes/197396/3 "2019-09-03T09:55:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 1, 2019, 9:55am UTC](https://discuss.elastic.co/t/what-does-illegalstateexception-unexpected-byte-error-on-transport-client-denotes/197396/4 "2019-10-01T09:55:08Z")

</div>

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