简体   繁体   中英

Spring Boot - Lot of invalid requests and Socket accept failed java.io.IOException: Too many open files

I have running machine with Spring (Spring Boot 1.5.2.RELEASE) application. Recently I'm receiving a lot of warnings in my log file:

.w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: null; nested exception is java.net.SocketTimeoutException

I've checked with tcpdump and a lot of request don't have body (empty/null) or have incorrect body eg \\00\\00\\00\\00\\00\\00\\00speed":"23.3","user_id":106312}

The biggest problem is that after some time I'm starting to receiving exceptions in my app:

org.apache.tomcat.util.net.NioEndpoint   : Socket accept failed

java.io.IOException: Too many open files
    at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
    at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:241)
    at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:443)
    at java.lang.Thread.run(Thread.java:745)

ulimit -n says that limit of open files is set to 65536 so I think it's big enough.

I'm assuming that receiving big amount of invalid requests causes IOException but why? And what should I do to avoid it and fix it?

I guess you use web socket with spring boot. You can listen on only 65535 port maximum, you can't exceed this amount of value on a machine. You should check if you close properly your sockets.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM