ERR_CONTENT_LENGTH_MISMATCH while loading js files on tomcat server
failed to load resource content length mismatch
error content-length mismatch
nginx net::err_content_length_mismatch 200 ok
- OS: CntOS 6.5 minimal
- Tomcat: 7.0.53
- Deployed war file contains many .js and .css files
Issue: When the war file is deployed on tomcat, it gets exploded properly and the web portal works fine. Machine is idle for over 12 hours.
- I access tomcat page: works fine. Even the manager page opens fine.
- I launch my webportal, it does not load. Error: GET http://:8080/webportal/client/libs/jquery/jquery-ui-1.9.2.min.js net::ERR_CONTENT_LENGTH_MISMATCH 10.211.106.184/:63 I get this error for various other js files as well.
What i have tried:
- Not an issue with memory since sufficient memory is available.
- Tried to open the .js file in another tab, the page keeps loading for a long time and then stops loading. The file is not fully downloaded. Hence the content mismatch issue.
- Access to the same url from the local CentOS box using wget works but access from browser on remote box does not
- Once static file is accessed on appliance using vi editor (not saved only accessed), downloads from browser start working
- What could possibly be an issue here? Is there any compatibility issue with tomcat and CentOS.
- Note again that immediately after deployment everything works fine. Webportal does not work only after a few (>12 approx) hours of inactivity.
In conf/server.xml config file in apache tomcat folder set the "usesendfile" attribute to "false" as shown below:-
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" **useSendfile="false"**/>
Please refer to link: http://ci.apache.org/projects/tomcat/tomcat7/docs/config/http.html for more details.
ERR_CONTENT_LENGTH_MISMATCH while loading js files , ERR_CONTENT_LENGTH_MISMATCH while loading js files on tomcat server. Configuration: OS: CntOS 6.5 minimal Tomcat: 7.0.53 Deployed war file contains � Download file to tomcat server from URL. 0. ERR_CONTENT_LENGTH_MISMATCH while loading js files on tomcat server. 0. Tomcat: The requested resource is not
Since this is the first Google hit for the query
"tomcat" net::ERR_CONTENT_LENGTH_MISMATCH, I'll share what I did in my case to solve the problem. For me, the jsp pages in the application loaded normally, but some CSS and JS files (e.g. jQuery) failed to load, exactly with this net::ERR_CONTENT_LENGTH_MISMATCH error.
This happened after I had set the timeout parameter of the Tomcat server to -1, as described here:
connectionTimeoutThe number of milliseconds this Connector will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout.
It's in the
server.xml file in the
conf folder. Setting this to another value (60000) solved the problem for me.
ERR_CONTENT_LENGTH_MISMATCH on nginx and proxy on , Angular failed to load resource: net::err_content_length_mismatch In conf/ server.xml config file in apache tomcat folder set the "usesendfile" attribute to " false" as shown below:- ERR_CONTENT_LENGTH_MISMATCH while loading js files� I've tried to correct in various ways with various solutions of the Internet, changing the server.xml tomcat, permission of files and folders and several other attempts without success. Could anyone help me? Thank's!
Try to deploy your webapp to Tomcat 6 or Tomcat 8, sometimes it works. I have solved such a issue but I don't know why. So you can have a try. Maybe it works. Good luck!
- Must be a content length limit/restriction in your web server settings.
- Thanks Zee. However, the content length issue is because the loading of webpage stops before download of js file is complete. And this does work after the war is deployed. Only stops working if server is idle for 12 hours or more.
- Thanks Kunal. Setting
usesendfile=falsewould ensure that tomcat sends compressed responses and hence reducing the time required for transfer on slower networks. The has fixed the issue.
- @DhavalMetrani I don't think your conclusion ist correct. Setting usesendfile=false turns off compression and thus save cpu time.
- Thanks Glorfindel for the answer. It's been over 4 years since I posted this! Out of curiosity, does this work with any other timeout value? And did you have to wait for 12 hours before getting this error?
- The timeout value used to be 20000 and that worked too. I'm not sure if I needed to wait for 12 hours, I think restarting Tomcat already applied the new timeout settings.