var websocket = require('../src/websocket');
var artik = require('../lib/artik-sdk');

var auth_token = '';
var device_id = '';
var message_data = '';
var host = "api.artik.cloud"; 
var uri = "/v1.1/websocket?ack=true";
var port = 443;
var ssl_connection = 2;
var use_se = false;
var register_message = '{"sdid":"' + device_id + '","Authorization":"bearer ' + auth_token + '","type":"register"}';
var test_send_message = '{\"data\": ' + message_data + ',"sdid": "' + device_id +  '","type": "message"}';

var conn = new websocket(host, uri, port, ssl_connection, use_se);

conn.open_stream();

conn.on('connected', function(result) {
	console.log("Connect result: " + result);
	conn.write_stream(register_message);
});

conn.on('receive', function(message) {
        console.log("received: " + message);
        conn.write_stream(test_send_message);
});

process.on('SIGINT', function () {
    console.log("Close stream");
    conn.close_stream();
    process.exit(0);
});



@@ -177,10 +177,9 @@
 ud%22;
- 
 %0A
+
 var 
@@ -425,16 +425,17 @@
 data%5C%22: 
+%22
 ' + mess
@@ -446,16 +446,18 @@
 data + '
+%22 
 ,%22sdid%22:
@@ -754,20 +754,16 @@
 sage) %7B%0A
-    
     cons
@@ -799,54 +799,8 @@
 e);%0A
-        conn.write_stream(test_send_message);%0A
 %7D);%0A
@@ -919,9 +919,208 @@
 );%0A%7D);%0A%0A
+setInterval(function () %7B%0A%09conn.write_stream(test_send_message);%0A%7D, 1000);%0A%0AsetTimeout(function () %7B%0A    console.log(%22Time out, close stream%22);%0A    conn.close_stream();%0A    process.exit(0);%0A%7D, 5500);
 %0A

Fix test program