Looks like a new connection is created and destroyed for each message sent. Isn't this inefficient? After all, javascript is single-threaded, you could just stream the messages with one open connection and there are no race conditions/concuttrency problems to solve.