var mqtt = require('mqtt')
  , client = mqtt.connect('mqtt://USRNAME:PASSWORD@YOUR_MQTT_SERVER?clientId=CLIENT_ID');

var influx = require('influx');
var dbclient = influx({
  // or single-host configuration
  host : 'YOUR_INFLUXDB',
  port : 8086, // optional, default 8086
  username : 'USERNAME',
  password : 'PASSWORD',
  database : 'DATABASE'
});

client.subscribe('TOPIC/#');

client.on('message', function (topic, message) {
	var result  = toPoint(message);
	if (result) {
		var seriesName = result[0];
		var point = result[1];
		dbclient.writePoint(seriesName, point, function(err) {
			if(err) {
				console.error('Influx writePoint Error:' + err);
				throw err;
			}
		});
	}
});

function toPoint(message) {
	var temp = message.split(",");
	if (temp.length > 10) {
	   try {
		var name = temp[0];
		if (name.substring(0, 2) == "MX") {
			name = "MTX00";
		}
		var Bid = parseFloat(temp[1]);
		var Bc = parseInt(temp[2]);
		var Ask = parseFloat(temp[3]);
		var Ac = parseInt(temp[4]);
		var close = parseFloat(temp[5]);
		var high = parseFloat(temp[6]);
		var low = parseFloat(temp[7]);
		var TickQty = parseInt(temp[8]);
		var TQty = parseInt(temp[9]);
		var Ref = parseFloat(temp[10]);
		var Percent = ((close / Ref) - 1) * 100;
		Percent = Percent.toFixed(5);
		var points = {"Bid": Bid, "Bc": Bc, "Ask": Ask, "Ac": Ac, "close": close, "high": high, "low": low,
				"TickQty": TickQty, "TQty": TQty, "Ref": Ref, "Percent": Percent};
		return [name , points]; 
	   } catch (ex) {
   		console.error(ex);
  	   }
	} else {
		return null;
	}
}

@@ -667,16 +667,453 @@
 ow err;%0A
+%09%09%09%09dbclient = influx(%7B%0A                                  // or single-host configuration%0A                                    host : 'YOUR_INFLUXDB',%0A                                    port : 8086, // optional, default 8086%0A                                    username : 'USERNAME',%0A                                    password : 'PASSWORD',%0A                                    database : 'DATABASE'%0A                                %7D);%0A
 %09%09%09%7D%0A%09%09%7D

Fix timeout problem