title: TLS Error: socket hang up in nodejs
body: <p>I'am trying to connect on a server using tls in nodejs. Here is my code :</p>
  
  <pre><code>var options = {
    rejectUnauthorized: false //self signed certificate
  };
  co = require("tls").connect(5200, "my_host", options, function(){
     co.on("data", function(data) {
        //do domething
     })
  
  }
  </code></pre>
  
  <p>This is simplified code. If I catch the error event, I have a <code>ECONNRESET</code> error, if I don't, I've got this trace :</p>
  
  <pre><code>Error: socket hang up
  at SecurePair.error (tls.js:1001:23)
  at EncryptedStream.CryptoStream._done (tls.js:697:22)
  at EncryptedStream.read [as _read] (tls.js:493:12)
  at EncryptedStream.Readable.read (_stream_readable.js:320:10)
  at CleartextStream.onCryptoStreamFinish (tls.js:301:47)
  at CleartextStream.g (events.js:175:14)
  at CleartextStream.EventEmitter.emit (events.js:92:17)
  at finishMaybe (_stream_writable.js:354:12)
  at endWritable (_stream_writable.js:361:3)
  at CleartextStream.Writable.end (_stream_writable.js:339:5)
  </code></pre>
  
  <p>If I connect directly to my server using <code>openssl s_client -connect my_host:5200</code> it works great. Strange thing, with node version 0.10.*, it works on ubuntu 10.04, but not on my mac neither on ubuntu 12.04. My server is also a nodejs program running ubuntu 10.04. Not sure if all of this is related but any help would be great !
  Cheers</p>