Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Reusing the HTTPS connection to backend with NodeJS

Hi All,

My usecase is to reuse the connection while calling the backend services over HTTPS (2-way SSL). I have deployed the API proxy in APIGEE On Premise 4.16.05.02.

1)I am able to connect to my backend services with the request module of NodeJS as below.

var options = {

key: fs.readFileSync('./sample.key'),

cert: fs.readFileSync('./sample.crt'),

uri: url,

hostname: 'hostname',

port: 443,

method: 'GET',

agent: false,

};

request(options,function(err,res, body){

if (err || !res) {

return callback();

}

callback(null, body);

});

I have passed the following HTTP headers in the incoming request, however I do not see any significance performance improvement.

<Header name="Connection">Keep-Alive</Header>

<Header name="Keep-Alive">timeout=60</Header>

2)I have modified the above code to include the keepalive (agent:keepAliveAgent) to make sure that the connection is alive.

var keepAliveAgent = new require('https').Agent({ keepAlive: true });

when i pass the keepAliveAgent created as above to agent parameter of the options variable, i am getting the following errors :

Error: javax.net.ssl.SSLException: Received fatal alert: handshake_failure

1) I tried deploying the API proxy in 4.16.09.00 and getting the below error message.

[Error: socket hang up] message: 'socket hang up', code: 'ECONNRESET'

2)How do I resolve the SSL Handshake failure/socket hangup issues when using HTTPS Agent?

3)Any other suggestion on implementation of my usecase?

1 3 3,298
3 REPLIES 3