Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reproduce problem with resources: create a html page with several images #115

Closed
wants to merge 3 commits into from

Conversation

asolntsev
Copy link
Contributor

No description provided.

@asolntsev asolntsev added this to the 2.0.0 milestone Jan 15, 2023
@asolntsev asolntsev self-assigned this Jan 15, 2023
in our case, it was `IllegalStateException: unexpected message type: DefaultHttpResponse` in case of "304 Not Modified" and "404 Not Found" responses.
@asolntsev asolntsev force-pushed the fix-problem-with-netty4-resources branch from 96f2cc9 to c0596f2 Compare January 15, 2023 10:18
@xabolcs
Copy link
Collaborator

xabolcs commented Jan 16, 2023

Maybe nitpicking, but in commit "log the error when Netty failed to print out response" you wrote unexpected message type: DefaultHttpResponse, but in the test I got unexpected message type: DefaultFullHttpResponse, state: 1 where state 1 is ST_CONTENT_NON_CHUNK:

    09:40:35,392 ERROR ~ failed to serve GET /img/benks-kyiv-4.jpeg (status: 404 Not Found)
    io.netty.handler.codec.EncoderException: java.lang.IllegalStateException: unexpected message type: DefaultFullHttpResponse, state: 1
        at io.netty.handler.codec.http.HttpObjectEncoder.write(HttpObjectEncoder.java:108)
        at io.netty.channel.CombinedChannelDuplexHandler.write(CombinedChannelDuplexHandler.java:346)
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:879)
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863)
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968)
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856)
        at io.netty.handler.stream.ChunkedWriteHandler.doFlush(ChunkedWriteHandler.java:302)
        at io.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:131)
        at io.netty.channel.AbstractChannelHandlerContext.invokeFlush0(AbstractChannelHandlerContext.java:923)
        at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:941)
        at io.netty.channel.AbstractChannelHandlerContext$WriteTask.run(AbstractChannelHandlerContext.java:1247)
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
    Caused by: java.lang.IllegalStateException: unexpected message type: DefaultFullHttpResponse, state: 1
        at io.netty.handler.codec.http.HttpObjectEncoder.throwUnexpectedMessageTypeEx(HttpObjectEncoder.java:348)
        at io.netty.handler.codec.http.HttpObjectEncoder.encodeFullHttpMessage(HttpObjectEncoder.java:305)
        at io.netty.handler.codec.http.HttpObjectEncoder.encode(HttpObjectEncoder.java:162)
        at io.netty.handler.codec.http.HttpObjectEncoder.write(HttpObjectEncoder.java:97)
        ... 18 more

It dies because the message is a FullHttpMessage and the state is not ST_INIT so is something is already sent out.

Browsing HttpObjectEncodeer.encode() there are a few hints how these message types relate to states.
But I still don't know that servexxx() should use FullHttpResponse and something is wrong with sending the headers before, or the serverxxx() shouldn't use FullHttpResponse because the headers are sent already. 🙃

@xabolcs
Copy link
Collaborator

xabolcs commented Jan 16, 2023

There isn't much in the "New and noteworthy in 4.0" document, but it worth to read.

And here is the referenced http snoop example: Package io.netty.example.http.snoop

@asolntsev
Copy link
Contributor Author

I registered an issue for replay-netty4: #157

@asolntsev asolntsev closed this Apr 18, 2023
@asolntsev asolntsev deleted the fix-problem-with-netty4-resources branch April 18, 2023 06:33
@asolntsev asolntsev removed this from the 2.0.0 milestone Apr 18, 2023
@asolntsev asolntsev added the bug label Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants