Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 6.0.36 not reporting why it responded with 400

Tags:

java

tomcat

I have a tomcat server and java client with java.net.HttpUrlConnection sending messages. Usually all works fine, but there some requests the client sends out which are responded with a 400 http error.

The problem is that nothing is shown on tomcat logs. I even tried to put .level=fine and other log level changes, and still no exception or error was shown.

I'm suspecting bad encoding in request or something like that, but tomcat doesn't give me any clues.

By the way, the URL is OK. I also see the request reaches the server but not to my servlet. It appears tomcat gets the message, declares it bad and doesn't log what's wrong.

Can anybody think of a way to see the 400 reason? Thank you

like image 225
user967710 Avatar asked Sep 12 '13 21:09

user967710


People also ask

How do I know if Tomcat is listening?

A simple way to see if Tomcat is running is to check if there is a service listening on TCP port 8080 with the netstat command. This will, of course, only work if you are running Tomcat on the port you specify (its default port of 8080, for example) and not running any other service on that port.

How much traffic can Tomcat handle?

The default installation of Tomcat sets the maximum number of HTTP servicing threads at 200. Effectively, this means that the system can handle a maximum of 200 simultaneous HTTP requests.


Video Answer


2 Answers

I finally figured out - I saw that the size of the total headers + size of data written to OutputStream - was exceptionally high - and so I defined in the Tomcat HTTP connector:

Connector port="8080" protocol="HTTP 1/1" maxPostSize="10485760" maxHttpHeaderSize="10485760"/

It is a shame Tomcat doesn't just tell me this, and I had to guess my - I will report this as a bug.

Thank you

like image 72
user967710 Avatar answered Oct 26 '22 17:10

user967710


This is a very nice issue to be discussed about. I also faced the same issue in my organization's work. I was clueless about it as there were no good logging about it in catalina.out or in our application logs. Http calls made from client apps to the API that was running in Tomcat_8 were getting rejected by the server with 400 bad request. Only Tomcat locahost_access logs records it by printing the 400 http status fro the request. After I increased the http header size the issue got resolved.

like image 39
Ayaskant Avatar answered Oct 26 '22 19:10

Ayaskant