Nodejs, best method for getting file uploading progress

First, I apologize if this is an immature question without proper research before asking. My question is, in Nodejs (with Express), for a fileuploading application, what is the best method to response back to client (javascript of the page) the percentage (progress) of the uploading back to the client: My option is either Long Polling or WebSocket (socket.io).

  • In a nodejs turorial video, I see they use long polling. For example:
var form = new formidable.IncomingForm();

form.uploadDir = __dirname+ '/uploaded';

res.writeHead(200, {
  'Content-type': 'text/plain'
});

form.parse(req, function(err, fields, files) {
  if (err) throw err;
  // console.log(files);
});

form.on('progress', function(bytesReceived, bytesExpected) {

  var progress = 100*bytesReceived/bytesExpected;
  console.log(progress);
      res.write(progress.toString());
});

Which is writing the data back without ending the connection.

  • However, looking around stackoverflow and asking other people
    opinion. I was suggested with using socket.io but this require some
    additional code that seem unnecessary for such simple task.

So which is the correct and proper solution, and what are theirs drawback?