title: ActiveMQ remote connections refused despite 0.0.0.0 in broker URL
body: <p>I have an ActiveMQ v5.7.0 broker, running in Karaf v2.3.3, that I want to enable for remote connections.  I've set the broker URL to 0.0.0.0:61616, to enable it to listen to network traffic.  I've opened the firewall to allow the traffic from the client machines.  However, all remote connections are being refused.  A quick netstat seems to tell me that the broker isn't listening outside of localhost.</p>
  
  <pre><code>jeremy@server:~$ netstat -pan | grep 61616
  tcp6       0      0 127.0.0.1:61616         :::*                    LISTEN      -               
  </code></pre>
  
  <p>Looking at the broker via <a href="http://hawt.io/" rel="nofollow">Hawtio</a> tells me that the URL looks as it should.</p>
  
  <pre><code>Transport connectors    Openwire: tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600
  </code></pre>
  
  <p>The firewall is definitely OK, as the connections are being refused rather than just being dropped.</p>
  
  <p>The broker is responding correctly to connections from localhost.</p>
  
  <pre><code>2013-10-14 17:34:29 Connected to localhost:61613
  </code></pre>
  
  <p>This is the sort of error I get from remote connections:-</p>
  
  <pre><code>Error connecting to xxx.xxx.xxx.xxx:61613: IO::Socket::INET: connect: Connection refused at /usr/local/share/perl/5.14.2/Net/Stomp.pm line 102.
  </code></pre>
  
  <p><strong>EDIT</strong>: telnet output added</p>
  
  <p>Localhost port 61613</p>
  
  <pre><code>jeremy@server:~$ telnet localhost 61613
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  </code></pre>
  
  <p>Remote connection port 61613</p>
  
  <pre><code>jeremy@other-server:~$ telnet xxx.xxx.xxx.xxx 61613
  Trying xxx.xxx.xxx.xxx...
  telnet: Unable to connect to remote host: Connection refused
  </code></pre>
  
  <p>Localhost connection port 61616 (this one is interesting)</p>
  
  <pre><code>jeremy@server:~$ telnet localhost 61616
  Trying 127.0.0.1...
  Connected to localhost.
  Escape character is '^]'.
  ðActiveMQ       Þ
  MaxFrameSizÿÿÿ  CacheSize
  CacheEnabledSizePrefixDisabled MaxInactivityDurationInitalDelay'TcpNoDelayEnabledMaxInactivityDurationu0TightEncodingEnabledStackTraceEnabledPuTTYConnection closed by foreign host.
  </code></pre>
  
  <p>Remote connection port 61616</p>
  
  <pre><code>jeremy@other-server:~$ telnet xxx.xxx.xxx.xxx 61616
  Trying xxx.xxx.xxx.xxx...
  telnet: Unable to connect to remote host: Connection refused
  </code></pre>
  
  <p><strong>EDIT</strong>: remote server karaf log output added</p>
  
  <pre><code>2013-10-15 19:00:46,599 | ERROR | c.event.invited] | faultJmsMessageListenerContainer | .DefaultMessageListenerContainer  909 | 69 - org.springframework.jms - 3.2.4.RELEASE | Could not refresh JMS Connection for destination 'Consumer.notifications.VirtualTopic.event.invited' - retrying in 5000 ms. Cause: Error while attempting to add new Connection to the pool; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://xxx.xxx.xxx.xxx:61616. Reason: java.net.ConnectException: Connection refused
  </code></pre>
  
  <p>Here's the broker.xml.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
    xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
    xmlns:amq="http://activemq.apache.org/schema/core"&gt;
  
    &lt;ext:property-placeholder /&gt;
  
    &lt;broker xmlns="http://activemq.apache.org/schema/core"
      brokerName="jellyfish-messaging"
      dataDirectory="${karaf.data}/activemq/localhost"
      useShutdownHook="false"
      persistent="true"
      schedulerSupport="true"
      startAsync="true"&gt;
  
      &lt;destinationPolicy&gt;
        &lt;policyMap&gt;
          &lt;policyEntries&gt;
            &lt;policyEntry topic="&gt;" producerFlowControl="true" memoryLimit="1mb"&gt;
              &lt;pendingSubscriberPolicy&gt;
                &lt;vmCursor /&gt;
              &lt;/pendingSubscriberPolicy&gt;
            &lt;/policyEntry&gt;
            &lt;policyEntry queue="&gt;" producerFlowControl="true" memoryLimit="1mb"&gt;
            &lt;/policyEntry&gt;
          &lt;/policyEntries&gt;
        &lt;/policyMap&gt;
      &lt;/destinationPolicy&gt; 
  
      &lt;persistenceAdapter&gt;
        &lt;kahaDB directory="${karaf.data}/activemq/localhost/kahadb"/&gt;
      &lt;/persistenceAdapter&gt;
  
      &lt;systemUsage&gt;
          &lt;systemUsage&gt;
              &lt;memoryUsage&gt;
                  &lt;memoryUsage limit="64 mb"/&gt;
              &lt;/memoryUsage&gt;
              &lt;storeUsage&gt;
                  &lt;storeUsage limit="100 gb"/&gt;
              &lt;/storeUsage&gt;
              &lt;tempUsage&gt;
                  &lt;tempUsage limit="50 gb"/&gt;
              &lt;/tempUsage&gt;
          &lt;/systemUsage&gt;
      &lt;/systemUsage&gt;
  
      &lt;!-- The transport connectors ActiveMQ will listen to --&gt;
      &lt;transportConnectors&gt;
          &lt;!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --&gt;
          &lt;transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;amp;wireformat.maxFrameSize=104857600"/&gt;
          &lt;transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;amp;wireformat.maxFrameSize=104857600"/&gt;
      &lt;/transportConnectors&gt;
  
    &lt;/broker&gt;
  
    &lt;bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&gt;
      &lt;property name="brokerURL" value="tcp://0.0.0.0:61616" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"&gt;
      &lt;property name="maxConnections" value="8" /&gt;
      &lt;property name="maximumActive" value="500" /&gt;
      &lt;property name="connectionFactory" ref="jmsConnectionFactory" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="resourceManager" class="org.apache.activemq.pool.ActiveMQResourceManager" init-method="recoverResource"&gt;
      &lt;property name="transactionManager" ref="transactionManager" /&gt;
      &lt;property name="connectionFactory" ref="jmsConnectionFactory" /&gt;
      &lt;property name="resourceName" value="activemq.localhost" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration"&gt;
      &lt;property name="connectionFactory" ref="pooledConnectionFactory" /&gt;
      &lt;property name="transacted" value="false" /&gt;
      &lt;property name="concurrentConsumers" value="10" /&gt;
    &lt;/bean&gt;
  
    &lt;bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"&gt;
      &lt;property name="configuration" ref="jmsConfig" /&gt;
    &lt;/bean&gt;
  
    &lt;reference id="transactionManager" interface="javax.transaction.TransactionManager" /&gt;
  
    &lt;service ref="pooledConnectionFactory" interface="javax.jms.ConnectionFactory"&gt;
      &lt;service-properties&gt;
        &lt;entry key="name" value="localhost"/&gt;
      &lt;/service-properties&gt;
    &lt;/service&gt;
  &lt;/blueprint&gt;
  </code></pre>
  
  <p>Can anyone tell me what I'm missing?</p>
  
  <p>Thanks,</p>
  
  <p>J.</p>