TCP Socket connection with Node.JS and AWS

I have deployed a node.js test application on AWS. Following is the server.js file:

var http = require("http");


var net = require("net");

var server=net.createServer(function(socket){
    socket.on('connection',function(socket){
        console.log('socket connection...');
    });
    socket.on('data',function(message){
        console.log('socket message:'+message);
        socket.write('You wrote:'+message);     
    });
    socket.on('error',function(error){
        console.log('error on socket message:'+error);      
    });
}).listen(1024);
/*
http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write(process.env.PORT);  
  console.log(process.env.PORT);
  response.end();
}).listen(8081);
*/

Http connection to the server works fine. A loadbalancer has been added with a TCP listener on 1024. But TCP connection to the server from a C# client fails, saying timeout error. I have tested the same code on localhost and it works fine. Does any more configurations needed on AWS for socket connections?

You need to end() your connection and send a FIN package

var server=net.createServer(function(socket){
    socket.on('connection',function(socket){
        console.log('socket connection...');
    });
    socket.on('data',function(message){
        console.log('socket message:'+message);
        socket.write('You wrote:'+message); 
        socket.end(); // <-- :)    
    });
    socket.on('error',function(error){
        console.log('error on socket message:'+error);      
    });
}).listen(1024);