TLS Socket connection through Nodejs

Im trying to establish a TLS socket connection to chat.facebook.com port:5222 through Nodejs. Im using the following code :

 var a=require('tls');
 var b=a.connect(5222,'chat.facebook.com',function(){console.log("connected");});
 b.on('error',function(error){console.log(error);})

But it is not getting connected and instead giving an error :

 [Error: 140089045411648:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown    protocol:../deps/openssl/openssl/ssl/s23_clnt.c:683:]

I have tried a similiar connection to encrypted.google.com:443 and console readily fired a "connected" .

Can someone guide me what i have been missing or what can be done to overcome this problem.

xmpp with tls uses "STARTTLS", a protocol upgrade from plaintext to encrypted. See http://xmpp.org/rfcs/rfc6120.html#tls for details.

(It means you have to send some unencrypted xml stuff first, and wait for the other end to confirm your choice to upgrade to TLS)