[英]Spring Boot - Lot of invalid requests and Socket accept failed java.io.IOException: Too many open files
我有運行機器與Spring (Spring Boot 1.5.2.RELEASE)
應用程序。 最近我在我的日志文件中收到了很多警告:
.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
我已經檢查過tcpdump
並且很多請求都沒有body(空/ null)或者有不正確的主體,例如\\00\\00\\00\\00\\00\\00\\00speed":"23.3","user_id":106312}
最大的問題是,經過一段時間后,我開始在我的應用程序中收到異常:
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
表示打開文件的限制設置為65536
所以我認為它足夠大。
我假設接收大量無效請求會導致IOException,但為什么呢? 我應該怎么做才能避免它並修復它?
我猜你使用帶有彈簧靴的網絡插座。 您最多只能偵聽65535端口,在一台機器上不能超過這個數值。 您應該檢查是否正確關閉了插座。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.