Q: node js websock process I was trying to process data which I got in my port. My code :
var WebSocketServer = require('ws').Server, wss = new WebSocketServer({ port: 5678 });

wss.on('connection', function connection(ws) {
    ws.on('message', function incoming(message) {

        function time_m() {
            var my_month=new Date()
            var month_name=new Array(12);
            month_name[0]="JAN"
            month_name[1]="FEB"
            month_name[2]="MAR"
            month_name[3]="APR"
            month_name[4]="MAY"
            month_name[5]="JUN"
            month_name[6]="JUL"
            month_name[7]="AUG"
            month_name[8]="SEP"
            month_name[9]="OCT"
            month_name[10]="NOV"
            month_name[11]="DEC"
            return month_name[my_month.getMonth()];      
        }
        function acc_array (n) {
            var arr_acc = new Array ("xAxis", "yAxis", "zAxis");
            return arr_acc[n];
        }
        function SOSjson() {

            function formatDate(d) {
                return d.getDate() + '-' + (time_m()) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + ":" + d.getMilliseconds() +" IST";
            }

            var SOSJSONObj = {};
            var observations = [];
            var record = [];
            var output = [];
            var version = "1.0.1";
            var sensor = "MySensor";
            var starttime;
            var name;
            var value;
            SOSJSONObj.version = version;
            SOSJSONObj.observations = observations;
            observations[0] = {sensor, record};
            var i;
            var msg = [];
            msg = message;
            console.log("Reading array value of messgae");
            console.log(msg[0]);

            for (i = 0; i < 3; i++) {
                //sleep(100);
                name = acc_array (i);
                value = msg;
                output.push({name, value});
                starttime = formatDate(new Date());
                record.push({starttime, output});
            }

            return JSON.stringify(SOSJSONObj);
        }   

        console.log('received: %s', message);
    });
    SOSjson();
    ws.send('something');
});

But it showed :
/home/root/node_modules/ws/websock_01.js:43
            observations[0] = {sensor, record};
                                     ^
    SyntaxError: Unexpected token ,
        at Module._compile (module.js:439:25)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)
        at Function.Module.runMain (module.js:497:10)
        at startup (node.js:119:16)
        at node.js:906:3

I am not able to find the the issue it is having. node js is not processing my data. The function calling I guess not working properly. or else the declaration may not be correct.

A: the string observations[0] = {sensor, record}; is not correct, if you want an object, then should look like this: 
observations[0] = {sensor : sensor, record : record}; 
or array : observations[0] = [sensor, record]; 
but in your case it is better to use an object
