0
votes

After I initially fixed my problem with nettys file chunks and getting the "unexpected message type: io.netty.handler.codec.http.DefaultHttpContent" error, I found out that a file that is sent after a chunked file will cause the same error according to my debug log (scroll to the very right):

19:50:25.992 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - Send header for file login.html
19:50:25.995 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer complete for login.html.
19:50:46.897 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - Send header for file index.html
19:50:46.900 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer complete for index.html.
19:50:46.926 [nioEventLoopGroup-3-2] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - Send header for file index.min.js
19:50:46.931 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 8192 for index.min.js.
19:50:46.934 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 16384 for index.min.js.
19:50:46.938 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 24576 for index.min.js.
[...]
19:50:47.775 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 729088 for index.min.js.
19:50:47.776 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 729115 for index.min.js.
19:50:47.777 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 729115 for index.min.js.
19:50:47.778 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer progress: 729115 / 729115 for index.min.js.
19:50:47.778 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - [id: 0x6a19f34a, /127.0.0.1:60222 => /127.0.0.1:443] Transfer complete for index.min.js.
19:50:47.778 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - Send file complete --- Starting new file index.min.css
19:50:47.779 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController - Send header for file index.min.css
19:50:47.784 [nioEventLoopGroup-3-3] DEBUG d.k.w.p.n.h.c.h.i.HtDocsController -  Transfer failed for index.min.css.java.lang.IllegalStateException: unexpected message type: io.netty.handler.codec.http.DefaultHttpContent (expected: HttpResponse)

The example implementation says that when using ssl no final empty chunk is needed. So what am I doing wrong?

UPDATE
The situation hasnt changed after my inital problem.
My pipeline looks like that:

SSL
HttpServerCodec
HttpObjectAggregator
ChunkedWriteHandler
FileHandler

I send the flies just like the netty 4 example with the difference that i only accept https.

I found out that the problem occures when the logger shows a different nioEventLoopGroup. The header of the index.min.js shows nioEventLoopGroup-3-2 where as the body has a nioEventLoopGroup-3-3 this might be the problem.

UPDATE
I had my ChannelHandler annotated with @ChannelHandler.Sharable which causes the different eventLoopGoups. I added the annotation because I use a ChannelHandler which decides on the first incomming request whether to tread it as a WebSocket or as a Http1.1 channel. I dynamically add and remove handlers.

When I remove the @ChannelHandler.Sharable the server will quit working as soon as the SSL handshake appears in the log

[nioEventLoopGroup-3-3] DEBUG io.netty.handler.ssl.SslHandler - [id: 0x03c4b130, /127.0.0.1:56868 => /127.0.0.1:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
1
Can you show some code, for example, how is your pipeline constructed and how are you sending the filesFerrybig

1 Answers

0
votes

The problem was the @ChannelHandler.Sharable which caused the header to be send without the body on the same eventLoop. I rewrote my WebSocket/HTTP selector so that is instantiates a channelhandler per initialization.

A Chunked File cannot be inside a sharable handler.