8 Replies Latest reply on Aug 6, 2012 4:58 AM by windy

    Unable to setup more EJB receivers: "Too many open files"

    windy

      Hello!

       

      My EJB client application uses a lookup similar to this posting: https://community.jboss.org/message/732900#732900. It connects with a few hundred different users to a JBoss server (7.1.1-final). Unfortunately, after about 1,000 connections, this stops working on the client side:

       

      WARN  [main] ConfigBasedEJBClientContextSelector   - EJB client context org.jboss.ejb.client.EJBClientContext@16db431a will have no EJB receivers due to an error setting up EJB receivers

      java.io.IOException: Too many open files

                at sun.nio.ch.IOUtil.initPipe(Native Method)

                at sun.nio.ch.EPollSelectorImpl.<init>(EPollSelectorImpl.java:49)

                at sun.nio.ch.EPollSelectorProvider.openSelector(EPollSelectorProvider.java:18)

                at java.nio.channels.Selector.open(Selector.java:209)

                at org.xnio.nio.NioXnioWorker.<init>(NioXnioWorker.java:120)

                at org.xnio.nio.NioXnio.createWorker(NioXnio.java:126)

                at org.jboss.remoting3.EndpointImpl.construct(EndpointImpl.java:137)

                at org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:60)

                at org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:73)

                at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:94)

                at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.<init>(ConfigBasedEJBClientContextSelector.java:77)

       

      It seems like the connections are never closed. Is there a way to do this? I found this posting with a connection handling example

       

      https://community.jboss.org/message/724714#724714

       

      but this does not work with the currect client library: ThreadLocalContextSelector.setCurrent(context) is not public.

        • 1. Re: Unable to setup more EJB receivers: "Too many open files"
          leonardo.devai

          This looks like an OS limitation rather than a JBoss issue.

           

          Are you using linux / unix?

          If yes, check your /etc/security/limits.conf and rise the limits up according to your needs...

           

          http://linux-quirks.blogspot.com/2011/02/too-many-open-files.html

           

          Leo

          • 2. Re: Unable to setup more EJB receivers: "Too many open files"
            windy

            Thanks for the suggestion, but is an increase of limits really the right way to deal with this? Sooner or later I will hit the next boundary, so would prefer a way to correctly close remote connections which are no longer used.

            • 3. Re: Unable to setup more EJB receivers: "Too many open files"
              leonardo.devai

              Some OS' are shipped with a low "max open files" threshold for security reasons and it is safe to increase it to a certain point.

               

              If this is something that will keep increasing forever, then perhaps you may need to rethink your logic.

              • 4. Re: Unable to setup more EJB receivers: "Too many open files"
                windy

                Since there will be more and more logins, the amount of open connections will constantly increase until the OS prohibits the creation of new ones. But even if I can increase the limits so it will work for now, this is hardly an acceptable solution.

                 

                What I am searching for is a way to close unused connections without shutting down the whole JVM.

                • 5. Re: Unable to setup more EJB receivers: "Too many open files"
                  jaikiran

                  So you have a properties file which has over 1000 remote connections configured?

                  • 6. Re: Unable to setup more EJB receivers: "Too many open files"
                    windy

                    What do you mean? A configuration value allowing more than 1,000 conections or a list of 1,000 accounts?

                     

                    Either way, none of those are configured.

                    • 7. Re: Unable to setup more EJB receivers: "Too many open files"
                      jaikiran

                      The exception stacktrace seemed to suggest that you are using the jboss-ejb-client.properties to configure those connections. But reading your post again, it looks like you are using programatic way to register them. Can you post the exact code where you are registering these connections?

                      • 8. Re: Unable to setup more EJB receivers: "Too many open files"
                        windy

                        jaikiran pai wrote:

                         

                        The exception stacktrace seemed to suggest that you are using the jboss-ejb-client.properties to configure those connections. But reading your post again, it looks like you are using programatic way to register them. Can you post the exact code where you are registering these connections?

                        You are correct, I am using Java code without any property files. Here it is:

                         

                        final Properties properties = new Properties();

                        properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");

                        properties.put("remote.connections", username);

                        properties.put("remote.connection." + username + ".host", "localhost");

                        properties.put("remote.connection." + username + ".port", "4447");

                        properties.put("remote.connection." + username + ".username", mailaddress);

                        properties.put("remote.connection." + username + ".password", password);

                        properties.put("remote.connection." + username + ".connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "true");

                        properties.put("remote.connection." + username + ".connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS","JBOSS-LOCAL-USER");

                        properties.put("remote.connection." + username + ".connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");

                         

                        final EJBClientConfiguration clientConfiguration = new PropertiesBasedEJBClientConfiguration(properties);

                        final ContextSelector<EJBClientContext> contextSelector = new ConfigBasedEJBClientContextSelector(clientConfiguration);

                         

                        EJBClientContext.setSelector(contextSelector);

                        Context ctx = getInitialContext();

                         

                        try {

                                  myController = (MyControllerRemote) ctx.lookup(lookupString);

                        } finally {

                                  ctx.close();

                        }