bentzy bentzy - 4 months ago 32
Android Question

MQTT Android not connecting to ActiveMq

I'm trying to connect an Android application to an ActiveMQ server.
I'm using ActiveMQ because my server already talks to the ActiveMQ server using JMS so it will be very beneficial for me to connect the android client to the JMS broker.

I've enabled MQTT in ActiveMQ following this page: http://activemq.apache.org/mqtt.html
and I had a small problem with any of the MQTT clients (IBM MQTT client or Paho MQTT Client) I've downloaded didn't recognize "mqtt://" url prefix so I tried to use tcp instead. This is how the configuration looks like in activemq.xml:

<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="tcp://0.0.0.0:1883"/>
</transportConnectors>


When I try to connect using any mqtt client example such as this one: http://mosquitto.org/2011/11/android-mqtt-example-project/ I'm unable to connect to the ActiveMQ and I get an error on the server side:

2013-09-05 12:34:17,550 | WARN | Transport Connection to: tcp://192.168.0.111:42148 failed: java.io.IOException: Unknown data type: 77 | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ Transport: tcp:///192.168.0.111:42148@1883


Any suggestions?
Thanks!

Answer

You haven't configured the MQTT transportConnector properly. Try this:

<transportConnectors>
  <transportConnector name="mqtt" uri="mqtt://localhost:1883"/>
</transportConnectors>

Notice that in yours you used the TCP uri prefix.