Hi,
I've noticed a strange behavior in node's http.request module.
I'm using node's built-in http module to make an HTTP request inside an
express handler. I believe I'm using http.request fairly conventionally.
Here is a code snippet:
app.post('/api/:userId/attachments/:examName/:attachmentName/render',function(req,res){
var htmlToSend = '';
req.on('data',function(s){
htmlToSend += s;
});
req.on('end',function(){
var pdfGeneratorRequest =
http.request({
host : PDF_GEN_HOST,
path : '/cgi-bin/render.cgi',
method : 'POST',
headers : {
'content-length' : htmlToSend.length,
'content-type' : 'text/html'
}
}, function(pdfGeneratorResponse) {
//handle the response
})
pdfGeneratorRequest.on('error',function(e){
var m = 'Error making request to PDF generator server';
console.log(m,e);
res.send(500,{error : m, message : e.message});
});
pdfGeneratorRequest.end(htmlToSend);
});
What I am finding, however, is that when the express server receives *six
or more* of these requests concurrently, nodejs mangles *one* of the HTTP
requests.
Here is an example of what shows up in the Apache log of the server
receiving the request:
10.181.194.183 - - [23/Dec/2013:16:14:03 +0000] "POST /cgi-bin/render.cgi
HTTP/1.1" 200 99865 "-" "-" 10.181.194.183 - - [23/Dec/2013:16:14:16
+0000] "POST /cgi-bin/render.cgi HTTP/1.1" 200 19742 "-" "-"
10.181.194.183 - - [23/Dec/2013:16:14:16 +0000] "POST /cgi-bin/render.cgi
HTTP/1.1" 200 19741 "-" "-"
10.181.194.183 - - [23/Dec/2013:16:14:15 +0000] "POST /cgi-bin/render.cgi
HTTP/1.1" 200 99865 "-" "-"
10.181.194.183 - - [23/Dec/2013:16:14:15 +0000] "POST /cgi-bin/render.cgi
HTTP/1.1" 200 99867 "-" "-"
10.181.194.183 - - [23/Dec/2013:16:14:17 +0000] "*ML>POST*/cgi-bin/render.cgi
HTTP/1.1" 400 25 "-" "-"
10.181.194.183 - - [23/Dec/2013:16:14:16 +0000] "POST /cgi-bin/render.cgi
HTTP/1.1" 200 99867 "-" "-"
Wireshark seems to confirm that the request HTTP method is getting mangled:
<https://lh4.googleusercontent.com/-Caoj66_ZfIw/UrhqKE0XvCI/AAAAAAAAAC4/WnQHUvn-GkY/s1600/Screen+Shot+2013-12-23+at+11.50.49+AM.png>
This occurs on node 0.10.24 on OS X 10.8.5
I'd appreciate any guidance anyone can offer as to why this might be
occurring and how to resolve it.
Thanks,
Jake
--
--
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/groups/opt_out.