You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am hosting a iisnode on Azure with Microsoft official SDK and node.js 0.6.10.
It seems iisnode cannot process chunked upload. Here is the client and server code. (Note the comment line on client code)
Client Code
var http = require('http'),
body = new Buffer('Testing 123', 'utf8'),
req;
req = http.request({
host: 'hostname',
port: 80,
method: 'POST',
path: '/',
headers: {
//'Content-Length': body.length,
'Content-Type': 'text/plain'
}
}, function (res) {
console.log('Server responded: ' + res.statusCode);
}).on('error', function (err) {
console.log('Failed to connect to server: ' + ex);
});
req.end(body);
Server Code
var http = require('http'),
port = process.env.port || parseInt(process.argv[2], 10);
http.createServer(function (req, res) {
console.log(req.headers);
req.on('data', function (chunk) {
console.log('Received: ' + chunk.toString('utf8'));
});
req.on('end', function () {
res.writeHead(200);
res.end('Hello, World!');
});
req.on('close', function () {
console.log('Closed prematurely.');
});
req.resume();
}).listen(port, function () {
console.log('Echo server started and listening to port ' + port + '...');
});
When I run it with local node.exe, everything works fine. The client receive 200 and the server receive the string.
But when I run it with iisnode on Azure, it will return 500. And what I see on the server side:
iisnode log
Echo server started and listening to port \\.\pipe\0ed3a093-b0a0-44bb-b341-91d8947900e7...
{ connection: 'keep-alive',
'transfer-encoding': 'chunked',
'content-type': 'text/plain',
host: 'hostname',
'x-original-url': '/' }
Closed prematurely.
I enabled IIS Failed Request Tracing, and here is the rough log:
IIS Failed Request Tracing
177 - GENERAL_REQUEST_ENTITY
Buffer Testing 12
178 - NOTIFY_MODULE_COMPLETION
ModuleName iisnode
Notification 128,
fIsPostNotificationEvent false
CompletionBytes 11
ErrorCode 0
Notification EXECUTE_REQUEST_HANDLER
ErrorCode The operation completed successfully. (0x0)
179 - GENERAL_READ_ENTITY_START
180 - GENERAL_READ_ENTITY_END
BytesReceived 0
ErrorCode 2147942438
ErrorCode Reached the end of the file. (0x80070026)
181 - MODULE_SET_RESPONSE_ERROR_STATUS
ModuleName iisnode
Notification 128
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 0
ErrorCode 109
ConfigExceptionInfo
Notification EXECUTE_REQUEST_HANDLER
ErrorCode The pipe has been ended. (0x6d)
But when I also send "Content-Length" along with my request, i.e. non-chunked mode, everything works fine. I receive this on iisnode log.
The issue is that IIS automatically decodes chunked transfer encoding of the request entity body, while iisnode module does not re-apply chunked encoding when relaying the message to the node.exe process.
The fix is for iisnode to re-apply chunking when forwarding messages to node.exe, as long as the original request message that IIS received was chunked.
I am hosting a iisnode on Azure with Microsoft official SDK and node.js 0.6.10.
It seems iisnode cannot process chunked upload. Here is the client and server code. (Note the comment line on client code)
Client Code
Server Code
When I run it with local node.exe, everything works fine. The client receive 200 and the server receive the string.
But when I run it with iisnode on Azure, it will return 500. And what I see on the server side:
iisnode log
I enabled IIS Failed Request Tracing, and here is the rough log:
IIS Failed Request Tracing
But when I also send "Content-Length" along with my request, i.e. non-chunked mode, everything works fine. I receive this on iisnode log.
iisnode log with Content-Length set
Looks like either I have something wrong with my code, something wrong with Azure handling the request, or something wrong with iisnode.
The text was updated successfully, but these errors were encountered: