3 Replies Latest reply on Jun 24, 2006 6:53 AM by Tim Fox

    Can not find a free port for use

    Jeremy Smartt Newbie

      I am using a durableSubscriber with JBoss Messaging. After running for a while and publishing to topics and retrieving them with the durableSubscriber I get the following error:

      java.io.IOException: Can not find a free port for use.


      I am not sure why I am getting this, I am pretty sure I am closing the connections after I check to see if there are new messages. I can run for about 50 receiveNoWait calls before it dies:

      InitialContext iniCtx = new InitialContext();
      Object tmp = iniCtx.lookup("/ConnectionFactory");
      TopicConnectionFactory tcf = (TopicConnectionFactory) tmp;
      TopicConnection conn = tcf.createTopicConnection("testuser", "testpassword");
      conn.setClientID("testclient");
      TopicSession session = conn.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);
      Topic topic = (Topic) iniCtx.lookup("topic/someTopic");
      
      conn.start();
      TopicSubscriber topicSubscriber = session.createDurableSubscriber(topic, "testclient");
      
      System.out.println("starting close topic: " + topicName);
      TextMessage tm = (TextMessage) topicSubscriber.receiveNoWait();
      topicSubscriber.close();
      conn.stop();
      session.close();
      conn.close();
      iniCtx.close();
      conn = null;