You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2019/11/21 17:58:51 UTC

[Bug 63949] New: ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO Connector with HTTPS

https://bz.apache.org/bugzilla/show_bug.cgi?id=63949

            Bug ID: 63949
           Summary: ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO
                    Connector with HTTPS
           Product: Tomcat 9
           Version: 9.0.20
          Hardware: Macintosh
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Util
          Assignee: dev@tomcat.apache.org
          Reporter: justin.wong@edge-technologies.com
  Target Milestone: -----

Created attachment 36892
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36892&action=edit
patch for NioEndpoint to use pool writes when blocking & non-blocking

Product: Tomcat 9.0.20+
Component: tomcat/java/org/apache/tomcat/util/net/NioEndpoint.java
Platform: macOS Mojave 10.14.6
Java version: 1.8.0_202 (Oracle Corporation)

Using the NIO Connector with SSL, I am seeing issues with the chunked
responses. It's been sporadic, but repeatable with my application within 20
attempts (though usually just the first after a fresh start is enough). Tried
on 8.5.40 and 8.5.47, and did not experience the issue. 

It shows up in Chrome as: 

> net::ERR_INCOMPLETE_CHUNKED_ENCODING

Going back to older Tomcat versions, we were able to narrow it down to 9.0.20
being the first version with the issue, specifically this commit: 

https://github.com/apache/tomcat/commit/4377d2db40

With the move to a straight write during non-blocking writes, the case for a
non-blocking write with a shared selector is different. By reverting back to a
pool write, I was able to make fix the issue. 

Attached patch applies to master branch, commit
0872b1a498610b008acbdaa719895ae15370359a.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63949] ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO Connector with HTTPS

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63949

--- Comment #3 from justin.wong@edge-technologies.com ---
Made that change, and don't have the problem anymore. 

Would adding that write loop back in be a possibility? 

Thanks,
Justin

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63949] ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO Connector with HTTPS

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63949

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEEDINFO                    |RESOLVED

--- Comment #4 from Remy Maucherat <re...@apache.org> ---
Ok, sorry for the trouble, the loop seemed only useful for blocking mode so I
didn't add it. The fix will be in Tomcat 9.0.30.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63949] ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO Connector with HTTPS

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63949

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
                 OS|                            |All

--- Comment #1 from Remy Maucherat <re...@apache.org> ---
-1 for the patch, you're doing a blocking write, so it "works". We'll examine
the issue eventually, but it most likely works fine as is.
If it is non blocking, the "selector" was not doing any magic, it simply does a
non blocking write, hence the patch.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63949] ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO Connector with HTTPS

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63949

--- Comment #5 from justin.wong@edge-technologies.com ---
Thanks for the fast turn around!

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 63949] ERR_INCOMPLETE_CHUNKED_ENCODING errors when using NIO Connector with HTTPS

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=63949

--- Comment #2 from Remy Maucherat <re...@apache.org> ---
The previous code was using a write loop, that's the only difference I can see
and you can try it.
Such as:
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -1273,9 +1273,13 @@
                 // registered for write once as both container and user code
can trigger
                 // write registration.
             } else {
-                if (socket.write(from) == -1) {
-                    throw new EOFException();
-                }
+                int n = 0;
+                do {
+                    n = socket.write(from);
+                    if (n == -1) {
+                        throw new EOFException();
+                    }
+                } while (n > 0 && from.hasRemaining());
             }
             updateLastWrite();
         }

If you are still experiencing an issue, please provide a test case (there's an
extensive non blocking write test in the Tomcat testsuite, which is not
failing).

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org