In async mode, servlet sets a ReadListener, and invokes onDataAvailable callbacks. If a client first sends out a POST request headers, then 2 seconds later sends out the payload. The ReadListener callbacks will never be invoked, and the client never receives a response. Glassfish 5.0 does not have this issue. This may not be a serious problem for HTTP/1.1 and servlet 3.1, but it is a problem for HTTP/2 and servlet 4.0 because HTTP/2 is ful-duplex. See the servlet code snippet in the Java EE tutorial example: https://javaee.github.io/tutorial/servlets013.html Client side command: telnet localhost 8080 POST /asyncioservlet HTTP/1.1 Host: localhost Content-Type: application/json Transfer-Encoding: chunked 10 {"key1":"value"} 0
This works for me. Note that the example is buggy - it does not handle the "-1" value returned by read when EOF is reached.
My mistake. This does work. Sorry about that. But I do have some issues that ReadListener and WriteListener callbacks never get called when using http/2 (https://github.com/grpc/grpc-java/pull/4738). Will update once I find a easy way to reproduce it.