Score:0

Tomcat 8.5.29 throws EOFException with 500 Internal Server Error

ng flag

I'm trying to access spring endpoint in AWS-EKS environment, I'm not recreate this issue locally but in production logs we see lot 500 Internal Server Error with below EOF Exception logged at same time:

logtype: tomcat-server message: Servlet.service() for servlet [com.abc.platform.xservices.rest.abcApplication] in context with path [/something] threw exception [org.glassfish.jersey.server.ContainerException: java.io.EOFException: Unexpected EOF read on the socket] with root cause java.io.EOFException: Unexpected EOF read on the socket at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:722) at org.apache.coyote.http11.Http11InputBuffer.access$300(Http11InputBuffer.java:40) at org.apache.coyote.http11.Http11InputBuffer$SocketInputBuffer.doRead(Http11InputBuffer.java:1072)

Any idea on why we see this in issue in production? Thanks.

Score:0
lu flag

It's an internal server error, which returns status code 500 in response

This may be caused by incorrect requests, but as well server code or overload may be the reason. If you have access to the server, check event logs.

See also

500 EOF when chunk header expected

Why might LWP::UserAgent be failing with '500 EOF'?

500 EOF instead of reponse status line in perl script

Apache 1.3 error - Unexpected EOF reading HTTP status - connectionreset

Error 500!

UPDATE On the other hand, if it's not response message, but a real exception, then it may be simply a bug, just like in old java And workaround may be putting getResponseCode() inside of try/catch and call second time on exception:

int responseCode = -1;
    try {
        responseCode = con.getResponseCode();
    } catch (IOException ex1) {
        //check if it's eof, if yes retrieve code again
        if (-1 != ex1.getMessage().indexOf("EOF")) {
            try {
                responseCode = con.getResponseCode();
            } catch (IOException ex2) {
                System.out.println(ex2.getMessage());
                // handle exception
            }
        } else {
            System.out.println(ex1.getMessage());
            // handle exception
        }
    }

Talking by connections number limit, read.

user3250064 avatar
ng flag
Thanks Alva, if we use Http 1.1 then by default it uses allowChunking as true.. is there a way to turn it off in tomcat config files? also this issue only happens in prod env and not in non-prod which has same tomcat configurations so its hard to understand. Thanks for your inputs.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.