title: Socket Hang Up when using https.request in node.js
body: <p>When using https.request with node.js v04.7, I get the following error:</p>
  
  <pre><code>Error: socket hang up
      at CleartextStream.&lt;anonymous&gt; (http.js:1272:45)
      at CleartextStream.emit (events.js:61:17)
      at Array.&lt;anonymous&gt; (tls.js:617:22)
      at EventEmitter._tickCallback (node.js:126:26)
  </code></pre>
  
  <p>Simplified code that will generate the error:</p>
  
  <pre><code>var https = require('https')
    , fs    = require('fs')
  
  var options = {
    host: 'localhost'
  , port: 8000
  , key: fs.readFileSync('../../test-key.pem')
  , cert: fs.readFileSync('../../test-cert.pem')
  }
  
  // Set up server and start listening
  https.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'})
    res.end('success')
  }).listen(options.port, options.host)
  
  // Wait a second to let the server start up
  setTimeout(function() {
    var clientRequest = https.request(options, function(res) {
      res.on('data', function (chunk) {
        console.log('Called')
      })
    })
  
    clientRequest.write('')
    clientRequest.end()
  }, 1000)
  </code></pre>
  
  <p>I get the error even with the server and client running on different node instances and have tested with port 8000, 3000, and 443 and with and without the SSL certificates. I do have libssl and libssl-dev on my Ubuntu machine.</p>
  
  <p>Any ideas on what could be the cause?</p>