Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

IllegalStateException with Message “unexpected message type: UnpooledUnsafeDirectByteBuf” from Netty #47

Closed
michaelahlers opened this issue Feb 17, 2014 · 12 comments

Comments

@michaelahlers
Copy link

I consistently get the following exception (from an ErrorListener#exceptionCaught(Throwable) instance registered with StreamingData) immediately after subscribing.

io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: UnpooledUnsafeDirectByteBuf
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:193) ~[netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:699) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.DefaultChannelHandlerContext.write(DefaultChannelHandlerContext.java:638) [netty-all-4.0.12.Final.jar:na]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:115) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.DefaultChannelHandlerContext.invokeWrite(DefaultChannelHandlerContext.java:645) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.DefaultChannelHandlerContext.access$2000(DefaultChannelHandlerContext.java:29) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.DefaultChannelHandlerContext$WriteTask.run(DefaultChannelHandlerContext.java:906) [netty-all-4.0.12.Final.jar:na]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354) [netty-all-4.0.12.Final.jar:na]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353) [netty-all-4.0.12.Final.jar:na]
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [netty-all-4.0.12.Final.jar:na]
        at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
Caused by: java.lang.IllegalStateException: unexpected message type: UnpooledUnsafeDirectByteBuf
        at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:80) ~[netty-all-4.0.12.Final.jar:na]
        at io.netty.handler.codec.http.HttpClientCodec$Encoder.encode(HttpClientCodec.java:94) ~[netty-all-4.0.12.Final.jar:na]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89) [netty-all-4.0.12.Final.jar:na]
        ... 12 common frames omitted

Workflow is very simple:

  1. Compile a simple CSDL query.
  2. Subscribe using the resulting Stream object.

And I never seem to get any results, even for interactions containing common terms. Also of possible interest, I get these shortly after:

java.io.IOException: Connection reset by peer
    at sun.nio.ch.FileDispatcherImpl.read0(Native Method) ~[na:1.7.0_45]
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39) ~[na:1.7.0_45]
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[na:1.7.0_45]
    at sun.nio.ch.IOUtil.read(IOUtil.java:192) ~[na:1.7.0_45]
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379) ~[na:1.7.0_45]
    at io.netty.buffer.UnpooledUnsafeDirectByteBuf.setBytes(UnpooledUnsafeDirectByteBuf.java:436) ~[netty-all-4.0.12.Final.jar:na]

Using 3.0.0-Beta1. Is this a problem in my environment or a bug with the library.

@dugjason
Copy link
Contributor

Hi @michaelahlers this is likely related to an account issue - we are investigating.
@zcourts this is likely related to OP-2136 - could you take a look please

@zcourts
Copy link
Contributor

zcourts commented Feb 18, 2014

@michaelahlers is this still happening?
I've been unable to reproduce it on OS X, Windows and Ubuntu.

@zcourts zcourts modified the milestone: 3.0.0 Feb 18, 2014
@zcourts
Copy link
Contributor

zcourts commented Mar 19, 2014

Closing this as it's not reproducible and may have been related to the temporary issue

@nbarabash
Copy link

I got this issue recently in my project. I even migrated to newer datasift client version (from "3.0.0-Beta3.5" to "3.1.0") but this did not help. I am running my service on Amazon EC2 server.

@zcourts
Copy link
Contributor

zcourts commented Oct 8, 2014

Hi @nbarabash - the original issue was related to an account specific problem.

Changing the client version shouldn't make a difference, the connection reset error implies the connection is being severed. A few things could possibly cause this including proxies, firewall rules or an issue on the DS server side. Since we've had no other report of this I'm inclined to think the issue not be the latter. That said....

Do you have a proxy between the client and DataSift?

What does your IP tables configuration looks like for outgoing connections on port 80 and 443?

To narrow that down, have you configured the client to connect with or without SSL? SSL will connect to DS on port 443, without SSL it's port 80.

@nbarabash
Copy link

Hi @zcourts,

I don`t have any proxy between the client and DataSift.
As far as my DataSift configuration has only username, apiKey values I assume client connects with SSL (from java code I can see default value for SSL is true -> protected boolean sslEnabled = true; )

The issue appeared accidentally, worked fine a few weeks even with old client "3.0.0-Beta3.5".

@zcourts
Copy link
Contributor

zcourts commented Oct 8, 2014

When did the issue first appear?
Has anything changed in your application between when it was working and when the issue started?
Have you double checked your EC2 firewall settings? Yes SSL is enabled by default so can you check to see if any firewall rules could be interfering with long running connections on port 443.

Can you give me a stack trace of what is produced when you get the issue?
If so, create another issue and I'll look into it.
As I said though, the connection reset implies the client is not at fault here so off the bat I suspect a firewall issue or an problem on the DS server side but we've had no other report of this happening.

@nbarabash
Copy link

@zcourts - this issue was spotted the first time on 2014-10-0. Data were lost for that period of time and I checked the logs, may be such exceptions were before that date, I am not sure. There is also another issue - client been disconnected from stream and does not connect again.

There were not any changes in application related to DataSift stream connection.

I`ll check EC2 firewall settings and will let you know.

The stack trace is:
2014-10-01 18:00:52.158 [nioEventLoopGroup-2-2] ERROR c.s.e.datasift.stream.ErrorHandler -Error in Datasift stream
io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: UnpooledUnsafeDirectByteBuf
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:193) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:657) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:715) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:650) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:657) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:715) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:705) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:740) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:241) ~[netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.higgs.ws.client.WebSocketStream.send(WebSocketStream.java:51) ~[ws-client-0.0.8-1.jar:na]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:624) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:144) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:624) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:144) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.Defau
t io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:624) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:144) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:624) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:144) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.notifyLateListener(DefaultPromise.java:624) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise.addListener(DefaultPromise.java:144) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:93) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.DefaultChannelPromise.addListener(DefaultChannelPromise.java:28) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at com.datasift.client.stream.StreamingData.pushUnsentSubscriptions(StreamingData.java:239) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData.subscribe(StreamingData.java:225) [datasift-java-3.0.0-Beta3.5.jar:na]
at com.datasift.client.stream.StreamingData$2.operationComplete(StreamingData.java:246) [datasift-java-3.0.0-Beta3.5.jar:na]
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:682) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise$LateListeners.run(DefaultPromise.java:847) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.DefaultPromise$LateListenerNotifier.run(DefaultPromise.java:875) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:370) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [netty-all-4.0.20.Final.jar:4.0.20.Final]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_07]
Caused by: java.lang.IllegalStateException: unexpected message type: UnpooledUnsafeDirectByteBuf\

@zcourts
Copy link
Contributor

zcourts commented Oct 9, 2014

That doesn't seem related to this issue. Opened #71 - I'll investigate Monday when I'm back in the office.

@perfectmight
Copy link

We had this problem too, here is the stack trace :

Feb 9 11:35:41 datasift-nexamaster io.netty.handler.codec.EncoderEx java.lang.IllegalStateException: unexpected message type: UnpooledUnsafeDirectByteBuf
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:107)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:193)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:241)
Feb 9 11:35:41 datasift-nexamaster at io.higgs.ws.client.WebSocketStream.send(WebSocketStream.java:51)
Feb 9 11:35:41 datasift-nexamaster at io.higgs.ws.client.WebSocketClientHandler.completeHandshake(WebSocketClientHandler.java:135)
Feb 9 11:35:41 datasift-nexamaster at io.higgs.ws.client.WebSocketClientHandler.channelRead0(WebSocketClientHandler.java:75)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:163)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:148)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:990)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:873)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:241)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:149)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:333)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:319)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:787)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:125)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
Feb 9 11:35:41 datasift-nexamaster at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
Feb 9 11:35:41 datasift-nexamaster at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
Feb 9 11:35:41 datasift-nexamaster at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
Feb 9 11:35:41 datasift-nexamaster Caused by: java.lang.IllegalStateException: unexpected message type: UnpooledUnsafeDirectByteBuf
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:78)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.http.HttpClientCodec$Encoder.encode(HttpClientCodec.java:106)
Feb 9 11:35:41 datasift-nexamaster at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89)

We usually have this problem after a couple of hours having our Datasift Streamer running.
Although, we are openning more than one stream at a time (for different clients).

We run the same code over two identical VMs on independant environements. One has low amount of streams(3) using one connection, the other has a high amount of streams(40) with multiple connections(2-3).

I took a look at the last 3 traces and (i'm probably wrong) I wonder if it could be related to multi-threading and the encoders (chunk vs initial state) ?

@zcourts
Copy link
Contributor

zcourts commented Feb 10, 2015

Do you know if this happens while the client is attempting to reconnect?
Which version of the client are you using 3.x.x?
The latest release ( I think for the last 4/5 releases) the client puts up to 200 subscriptions on a single websocket connection, for every 200 it adds one more websocket connection.

It's hard to say what could cause this other than an attempt to reconnect and there's a race condition which results in a message being written before the pipeline is configured or written at the end of the pipeline. Either of those would result in the Netty stack you've posted

Does this consistently happen every couple of hours?

@zcourts zcourts reopened this Feb 10, 2015
@perfectmight
Copy link

According to DataSiftConfig.java line 36, i have version 3.0.0 (http.userAgent("DataSift/" + versionPrefix + " Java/v3.0.0");)

Also, yes it happends everytime after a couple of hours. Each time we end up after a day or 2 to restart it.

I'll try to update the Datasift java api code and see if it solves the issue in the upcomming days !

Thank you !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants