6 Replies Latest reply on Mar 18, 2014 11:32 AM by clebert.suconic

    Address already in use with NettyAcceptor

    millen32

      I am developing one Spring application server with HotnetQ embedded to pubsub service. I have the next class described more below to manager HornetQ server.

      But, when I deploy my application I get the next error in tomcat console.

      I have been changing Netty acceptor port number, but problem persist, If I use other acceptor instead Netty it work fine, but I am interested in Netty Acceptor type.

      Setting ServerMQ configuration...
      Initializing ServerMQ...
      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl start
      INFO
      : HQ221000: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=data/journal,bindingsDirectory=data/bindings,largeMessagesDirectory=data/largemessages,pagingDirectory=data/paging)
      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl initialisePart1
      WARN
      : HQ222007: Security risk! HornetQ is running with the default cluster admin user and default password. Please see the HornetQ user guide, cluster chapter, for instructions on how to change this.
      mar
      12, 2014 1:42:44 PM org.hornetq.core.remoting.server.impl.RemotingServiceImpl <init>
      INFO
      : HQ221043: Adding protocol support CORE
      ServerMQ initialized!
      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl$SharedNothingLiveActivation run
      ERROR
      : HQ224000: Failure in initialisation
      java
      .net.BindException: Address already in use: bind
        at sun
      .nio.ch.Net.bind0(Native Method)
        at sun
      .nio.ch.Net.bind(Net.java:444)
        at sun
      .nio.ch.Net.bind(Net.java:436)
        at sun
      .nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
        at sun
      .nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at io
      .netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:102)
        at io
      .netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:479)
        at io
      .netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1000)
        at io
      .netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:457)
        at io
      .netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:442)
        at io
      .netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:842)
        at io
      .netty.channel.AbstractChannel.bind(AbstractChannel.java:194)
        at io
      .netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:331)
        at io
      .netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
        at io
      .netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
        at io
      .netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
        at java
      .lang.Thread.run(Thread.java:744)

      mar
      12, 2014 1:42:44 PM org.hornetq.core.server.impl.HornetQServerImpl start
      INFO
      : HQ221001: HornetQ Server version 2.4.1.Final (Fast Hornet, 124) [a681c9b2-a83a-11e3-b8ef-531df38c9cfa
      ]

      Here is my class implementation.

      @Component(value = "serverMQ")

      public class ServerMQ {

       

          private Configuration configuration;

       

          private ClientSessionFactory clientSessionFactory;

       

          private HornetQServer HornetQ;

       

          public ServerMQ() {

       

              System.out.println("Setting ServerMQ configuration...");

       

              // Instantiate server config.

              this.configuration = new ConfigurationImpl();

       

              // Server has persistence for messages.

              this.configuration.setPersistenceEnabled(false);

       

              // Server has user security authentication.

              this.configuration.setSecurityEnabled(false);

       

              Map<String, Object> nettyAcceptorAttrs = new HashMap<String, Object>();

              nettyAcceptorAttrs.put(TransportConstants.HOST_PROP_NAME, "localhost");

              nettyAcceptorAttrs.put(TransportConstants.PORT_PROP_NAME, 5555);

       

              this.configuration.getAcceptorConfigurations().clear();

              this.configuration.getAcceptorConfigurations().add(new TransportConfiguration(NettyAcceptorFactory.class.getName(), nettyAcceptorAttrs));

       

              this.init2();

          }

       

          public void init2() {

       

              try {

       

                  System.out.println("Initializing ServerMQ...");

       

                  this.HornetQ = HornetQServers.newHornetQServer(this.configuration);

                  this.HornetQ.start();

       

                  System.out.println("ServerMQ initialized!");

              } catch (Exception ex) {

       

                  try {

       

                      this.HornetQ.stop();

                  } catch (Exception exs) {

       

                      System.err.println("Stopping ServerMQ error:\n" + exs.getMessage());

                  }

       

                  System.err.println("ServerMQ initializing error:\n" + ex.getMessage());

              }

          }

       

       

          public ClientSessionFactory getClientSessionFactory() {

              return clientSessionFactory;

          }

       

       

      }

        • 1. Re: Address already in use with NettyAcceptor
          jbertram

          The error is coming from the JVM so I'm inclined to think it's valid.  Have you considered that the ports you've chosen actually are in use?

           

          When you say that other acceptors work, what others have you used?

          • 2. Re: Address already in use with NettyAcceptor
            clebert.suconic

            It's an error on his application. you should do a simple debug.. you had a simple programming error  in a past version you posted on StackOverFlow.

             

             

            BTW: this is the dev forums.. you should post on user's forum

            • 3. Re: Address already in use with NettyAcceptor
              millen32

              The response I got in SO was wrong, is not a bad coding by me, so I have posted here.

               

              Now I know was happening. Thank you for your attention.

               

              To report one "bug" to HornetQ developers What I have to do?

               

              Response:

              Ok, is "bug", in quotes, I have been trying some differents scenarios along last days. In the last one,

               

              I have developing one Stomp WebSocket server, along some days, this approach wasn´t found, but I have not any exception message to suggest me I was forgetting to import "hornetq-stomp-protocol.jar", with one exception message you can warning to other developers about this.

              • 4. Re: Address already in use with NettyAcceptor
                jbertram

                We can discuss the potential bug here and if it proves to be legitimate then one of us can open a JIRA.  What is the nature of the potential bug you've found?  Please describe it thoroughly.

                • 5. Re: Address already in use with NettyAcceptor
                  clebert.suconic

                  The first example you post was wrong.. I don't have a crystal ball to guess what you are doing wrong... if you found a bug state it clear.. provide an example showing it so

                  • 6. Re: Address already in use with NettyAcceptor
                    clebert.suconic

                    You haven't reported any bugs so far.. you have to post a code showing the bad behaviour on the code... so far all the code you've been posting is either an issue on Spring or on your code.

                     

                     

                    We can't fix issues on Spring BTW. It's not our product.