Skip to content

Problems with Content-Length using Undertow or Jetty #467

@marcinc81

Description

@marcinc81

Yesterday I was doing comparison of all 3 servers: Netty, Jetty and Undertow. By the way Undertow is the fastest one, Netty is next, last is Jetty. Really small difference: 7300req/s - 6300req/s. For sure no one will notice this difference in production.

Anyway, I changed server to Undertow as it is the winner and found weird issue. After changing some asset (eg. generated JavaScript from Gulp/Browserify), browser sends this error message:

GET http://localhost:8080/assets/js/forms.js net::ERR_CONTENT_LENGTH_MISMATCH

And indeed, in HTTP header Jooby sets content length different than sent file has in reality. Doesn't help reloading app, start / stop, mvn clean, etc. And this is weird. Probably this issue doesn't apply in a production where assets are static.

The same issue is with Jetty, but in this case this web server logs exception:

[2016-09-07 16:33:29,628]-[jetty task-48] WARN  org.eclipse.jetty.io.AbstractConnection - 
java.lang.NullPointerException: null
    at org.jooby.internal.jetty.JettyResponse.failed(JettyResponse.java:87) ~[jooby-jetty-1.0.0.CR7.jar!/:1.0.0.CR7]
    at org.eclipse.jetty.util.IteratingNestedCallback.onCompleteFailure(IteratingNestedCallback.java:65) ~[jetty-util-9.3.9.v20160517.jar!/:9.3.9.v20160517]
    at org.eclipse.jetty.server.HttpOutput$ReadableByteChannelWritingCB.onCompleteFailure(HttpOutput.java:1255) ~[jetty-server-9.3.9.v20160517.jar!/:9.3.9.v20160517]
    at org.eclipse.jetty.util.IteratingCallback.failed(IteratingCallback.java:401) ~[jetty-util-9.3.9.v20160517.jar!/:9.3.9.v20160517]
    at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:115) ~[jetty-io-9.3.9.v20160517.jar!/:9.3.9.v20160517]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) [jetty-util-9.3.9.v20160517.jar!/:9.3.9.v20160517]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) [jetty-util-9.3.9.v20160517.jar!/:9.3.9.v20160517]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]

Additionally Jetty has problem with serving one image (png, 1954544 bytes) - sends only first 800kB, and browser displays the same error (content length mismatch).

Switching back to Netty resolves the problem.

Cheers! :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions