Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No buffer space available (maximum connections reached?): connect #28

Open
nebuc opened this issue Jun 16, 2017 · 1 comment
Open

No buffer space available (maximum connections reached?): connect #28

nebuc opened this issue Jun 16, 2017 · 1 comment

Comments

@nebuc
Copy link

nebuc commented Jun 16, 2017

It Works fine, but with 20 req/seg Error: No buffer space available (maximum connections reached?): connect

any idea?

	    		final GelfConfiguration config = new GelfConfiguration(new InetSocketAddress(grayMachine, 12002))
	    	              .transport(GelfTransports.TCP)
	    	              .queueSize(512)
	    	              .connectTimeout(1000)
	    	              .reconnectDelay(1000)
	    	              .tcpNoDelay(true)
	    	              .sendBufferSize(32768);

    	        final GelfTransport transport = GelfTransports.create(config);

    	        final GelfMessageBuilder builder = new GelfMessageBuilder("","example.com")
    	                .level(gelfLevel_obj)
    	                .additionalField("machine", logIntegracion.getLoiMachin());

	            final GelfMessage message = builder.message(logIntegracion.getLoiTipo())
	                    .additionalField("time", logIntegracion.getLoiTiempo())
    	                .additionalField("endpoint", EndPoint)
	                    .build();

                // Returns false if there isn't enough room in the queue
                transport.send(message);

Error detail:

java.lang.IllegalStateException: failed to create a child event loop
	at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:68)
	at io.netty.channel.MultithreadEventLoopGroup.<init>(MultithreadEventLoopGroup.java:49)
	at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:61)
	at io.netty.channel.nio.NioEventLoopGroup.<init>(NioEventLoopGroup.java:52)
	at org.graylog2.gelfclient.transport.AbstractGelfTransport.<init>(AbstractGelfTransport.java:41)
	at org.graylog2.gelfclient.transport.AbstractGelfTransport.<init>(AbstractGelfTransport.java:62)
	at org.graylog2.gelfclient.transport.GelfTcpTransport.<init>(GelfTcpTransport.java:52)
	at org.graylog2.gelfclient.GelfTransports.create(GelfTransports.java:42)
	at org.graylog2.gelfclient.GelfTransports.create(GelfTransports.java:61)
	at com.kumointernet.web.dao.LogIntegracionDAO.guardar(LogIntegracionDAO.java:103)
	at org.apache.jsp.backoffice.jmeter_jsp._jspService(jmeter_jsp.java:114)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
	at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
	at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
	at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Unknown Source)
Caused by: io.netty.channel.ChannelException: failed to open a new selector
	at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:128)
	at io.netty.channel.nio.NioEventLoop.<init>(NioEventLoop.java:120)
	at io.netty.channel.nio.NioEventLoopGroup.newChild(NioEventLoopGroup.java:87)
	at io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(MultithreadEventExecutorGroup.java:64)
	... 46 more
Caused by: java.io.IOException: Unable to establish loopback connection
	at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source)
	at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.nio.ch.PipeImpl.<init>(Unknown Source)
	at sun.nio.ch.SelectorProviderImpl.openPipe(Unknown Source)
	at java.nio.channels.Pipe.open(Unknown Source)
	at sun.nio.ch.WindowsSelectorImpl.<init>(Unknown Source)
	at sun.nio.ch.WindowsSelectorProvider.openSelector(Unknown Source)
	at io.netty.channel.nio.NioEventLoop.openSelector(NioEventLoop.java:126)
	... 49 more
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
	at sun.nio.ch.Net.connect0(Native Method)
	at sun.nio.ch.Net.connect(Unknown Source)
	at sun.nio.ch.Net.connect(Unknown Source)
	at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
	at java.nio.channels.SocketChannel.open(Unknown Source)
	at sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(Unknown Source)
	... 58 more
@Zackysh
Copy link

Zackysh commented Oct 27, 2022

Until now I've noticed that the problem you're facing occurs when creating multiple GelfTransport instances, at certain point you exceed the maximum possible number of concurrent transports and SocketException is raised.

I propose two solutions:

  • If you need too many different transports, closing each transport after usage should avoid this problem ( I think stop() method does the trick ).
  • If you need a few transports (due to different hosts or just for the sake of having more than one), place them where you can reuse them instead of creating new ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants