title: heroku connection closed code=H13
body: <p>i deploy a simple nodejs server on heroku with ssl valid certificate</p>
  
  <pre><code>var https = require('https');
  var express = require('express');
  var bodyParser = require('body-parser');
  var fs = require('fs');
  
  var app = express();
  var cors = require('cors');
  
  var credentials = {
      key: fs.readFileSync('./cert/key.key'),
      cert: fs.readFileSync('./cert/cert.crt'),
      ca: fs.readFileSync('./cert/bundle.crt'),
      requestCert: true,
      rejectUnauthorized: false
  };
  
  var server = https.createServer(credentials, app);
  
  var io = require('socket.io')(server);
  
  app.use(cors()); 
  app.use(bodyParser.json({limit: '12mb'})); 
  app.use(bodyParser.urlencoded({limit: '12mb', extended: true }));
  
  io.on('connection', function(socket){
     console.log(socket);
     socket.on('authenticate', function(data){
  
        console.log(data);
     });
  });
  
  var port = process.env.PORT || 8080;
  
  server.listen(port, function () {
      console.log("server listen on", this.address());
  });
  
  server.on('clientError', function(err) {
      console.log('ERROR', err);
  });
  </code></pre>
  
  <p>the problem is that when i start the app i received this error</p>
  
  <pre><code>ERROR { Error: socket hang up
  at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:820:25)
  at emitOne (events.js:101:20)
  at TLSSocket.emit (events.js:188:7)
  at Socket._handle.close (net.js:492:12)
  at Socket.g (events.js:286:16)
  at emitOne (events.js:96:13)
  at Socket.emit (events.js:188:7)
  at TCP._handle.close [as _onclose] (net.js:492:12) code: 'ECONNRESET' }
  </code></pre>
  
  <p>when i try to connect by chrome to my server i received this error
  in server side</p>
  
  <pre><code>2017-01-05T15:03:43.465542+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/socket.io/?EIO=3&amp;transport=polling&amp;t=LblA3JZ" host=www.myapp.com request_id=51982ce9-99e3-4677-acb4-a0f14eb88999 fwd="95.251.90.218" dyno=web.1 connect=1ms service=2ms status=503 bytes=0
  2017-01-05T15:03:43.460178+00:00 app[web.1]: ERROR Error: 140414443095936:error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request:../deps/openssl/openssl/ssl/s23_srvr.c:394:
  </code></pre>
  
  <p>and this error in the client side</p>
  
  <pre><code>XMLHttpRequest cannot load https://www.myapp.com/socket.io/?EIO=3&amp;transport=polling&amp;t=LblDK25. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.0.8:8100' is therefore not allowed access. The response had HTTP status code 503.
  </code></pre>
  
  <p>at first moment i thought that was socket.io but the problem persist also with normal REST operation.
  now i think that i a SSL problem. i create a valid certificate with godaddy provider and i upload it to heroku with success. in fact if i try to connect to my app through https connection the certificate is valid. maybe the problem is when i try to upload this certificates into my nodejs app.someone can help me? thanks in advance</p>