Rajat Talwar
Rajat Talwar

Reputation: 11912

Server stops responding after a while

I am facing a weird problem where I start my https server using node https module and self-signed certificate-

var express = require('express');
var app = express();
var https = require("https");    

var privateKey  = fs.readFileSync(require.toUrl(appConfig.get("ssl:key")), 'utf8');
var certificate = fs.readFileSync(require.toUrl(appConfig.get("ssl:cert")), 'utf8');

var credentials = {key: privateKey, cert: certificate};

https.createServer(credentials, app).listen(443);
console.log('listening on port# ' + 443);

The server keeps responding to get/put/post requests for few hours and then takes forever to return response to requests.

I am using forever module and forever logs give no error or termination commands.

Any help is greatly appreciated

Upvotes: 4

Views: 1733

Answers (2)

Rajat Talwar
Rajat Talwar

Reputation: 11912

Figured it out,we had a ping api which was coming from the clients and 'Connection' header was set to default value keep-alive which was keeping the connections open .

Upvotes: 1

Whocares
Whocares

Reputation: 96

Since there are no logs, its going to be hard to tell, but try this:

    var app = require("express")();
    var privateKey  = fs.readFileSync(require.toUrl(appConfig.get("ssl:key")), 'utf8');
    var certificate = fs.readFileSync(require.toUrl(appConfig.get("ssl:cert")), 'utf8');
    var credentials = {key: privateKey, cert: certificate};
    var https = require("https").Server(credentials, app);
    https.listen(443, function() {
    console.log('listening on port# ' + 443);
    });

secondly, are u sure no other service is interfering on port 443?

Upvotes: 0

Related Questions