The server looks like this:

var https = require('https');
var fs = require('fs');

var tlsOptions = {
key: fs.readFileSync('ssl/server/privatekey.pem'),
cert: fs.readFileSync('ssl/server/certificate.pem'),
ca: [ 
fs.readFileSync('ssl/server/root.pem')
],
requestCert: false
};

var server = https.createServer(tlsOptions, function(req, res) {
console.log('test request for ' + req.url);
console.log(req.headers);
res.end('ok');
});

server.listen(19862, function() {
console.log('server listening on port 19862');
});


and this is the client:

var fs = require('fs');
var https = require('https');

var httpsAgent = new https.Agent({
hostname: '127.0.0.1',
port: 19862,
rejectUnauthorized: false,
maxSockets: 1
});

function doTestRequest() {

var requestOptions = {
hostname: '127.0.0.1',
port: 19862,
path: '/test',
method: 'GET',
rejectUnauthorized: false,

agent: httpsAgent
};

console.log('send request');

var req = https.request(requestOptions, function(res) {
console.log(res.statusCode, res.headers);
});
req.end();
};

//setInterval(doTestRequest, 500);
doTestRequest();
doTestRequest();
doTestRequest();


On Monday, March 24, 2014 5:10:57 PM UTC+1, Fedor Indutny wrote:
>
> Hello!
>
> How are you doing client requests? Are you calling `.end()` on each of 
> them?
>
> Could you paste some code snippets here to let us help you?
>
> Cheers!
>
>
> On Mon, Mar 24, 2014 at 6:27 PM, <[email protected] <javascript:>>wrote:
>
>> I have a https server and a https client, both with node. I want to send 
>> many https requests to the server but all over the same SSL connection. I 
>> tried to create a https agent like this:
>>
>> var myAgent = new https.Agent({
>> hostname: '127.0.0.1',
>> port: 19862,
>> maxSockets: 1
>>  });
>>
>> Then I use this agent on every https.request() with options.agent. But 
>> this doesn't work. Only the first request is sent to the server. The 
>> following requests never arrive at the server and also the callback of 
>> https.request() is never called. When sniffing the traffic with wireshark I 
>> see that after the first request nothing is sent anymore, but the TCP 
>> connection stays open untill I stop the client.
>>
>> When i increase maxSockets to 5 only the first 5 requests are sent. All 
>> the following requests never arrive at the server. And for every of the 5 
>> first requests the client establishes a new TCP connection and does the 
>> whole SSL handshake.
>>
>> I also tried without setting any agent in the request options. Like this 
>> the global agent will be used. Then I can send as many requests as I want, 
>> and all of them arrive at the server. But a new TCP connection with the 
>> whole SSL handshake is made for every request, which is what I really want 
>> to avoid. 
>>
>> I hope that somebody can help me with this.
>>
>> -- 
>> -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]<javascript:>
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to