I am using Spring boot WebSocketConfigurer to create a websocket according to the following code to create a presence system. My users will connect to it and it will track their presence.
@Configuration @EnableWebSocket public class WebSocketServerConfiguration implements WebSocketConfigurer { private final PresenceListener presenceListener; Logger logger = Logger.getLogger(WebSocketServerConfiguration.class.getName()); @Autowired public WebSocketServerConfiguration(StringRedisTemplate stringRedisTemplate){ this.presenceListener = new PresenceListener(stringRedisTemplate); } @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(new WebSocketHandler() { @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { logger.info("afterConnectionEstablished:"+session.toString()); } @Override public void handleMessage(WebSocketSession session, WebSocketMessage<?> message) throws Exception {
}
Some time after deployment, I begin to receive the following Exceptions:
java.io.IOException: Too many open files at sun.nio.ch.ServerSocketChannelImpl.accept0( java.base@9-internal /Native Method) ~[na:na] at sun.nio.ch.ServerSocketChannelImpl.accept( java.base@9-internal /ServerSocketChannelImpl.java:424) ~[na:na] at sun.nio.ch.ServerSocketChannelImpl.accept( java.base@9-internal /ServerSocketChannelImpl.java:252) ~[na:na] at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:443) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11] at java.lang.Thread.run( java.base@9-internal /Thread.java:804) [na:na]
Please help with this problem.
source share