Skip to content Skip to sidebar Skip to footer

Local Broker (mqtt) Based Publish/subscribe Using Android Application

In my current project, I am using MQTT local broker based implementation and setup using this link. The local broker based MQTT implementation is working perfectly. At initially, I

Solution 1:

The problem is your URI is using the http:// scheme. http:// is for connecting to HTTP servers not MQTT brokers.

You need to use the tcp:// URI for Android (this might work for NodeJS as well, but mqtt:// definately works for NodeJS

mqtt://192.168.0.105

var mqtt = require('mqtt');
var client = mqtt.connect('mqtt://192.168.0.105');
setInterval(function() {
var data = {
     "tempValue" : Math.random(),
     "unitOfMeasurement" : 'C'
     };
client.publish('tempMeasurement', JSON.stringify(data));
}, 5000);

Post a Comment for "Local Broker (mqtt) Based Publish/subscribe Using Android Application"