One of our recent projects involve a scalable mult-chatroom service. Deciding to go the route of Node+socket.io for scalable and performance oriented service we started with the official socket.io tutorial at (http://socket.io/get-started/chat/). That worked wonderfully . As the next step we went ahead and hosted it on Azure!
Here is what the socket told us!
issnode encountered an error when processing the request.
HRESULT: 0×2
HTTP status: 500
HTTP subStatus: 1001
HTTP reason: Internal Server Error
You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is ‘true’.
In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.
The node.exe process has not written any information to stderr or iisnode was unable to capture this information. Frequent reason is that the iisnode module is unable to create a log file to capture stdout and stderr output from node.exe. Please check that the identity of the IIS application pool running the node.js application has read and write access permissions to the directory on the server where the node.js application is located. Alternatively you can disable logging by setting system.webServer/iisnode/@loggingEnabled element of web.config to ‘false’.
After some research we realized that the problem is in the port creation. In the above getting started tutorial, port number is created using the following code;
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
http.listen(3000, function(){
console.log('listening on *:3000');
});
In order to make the above code work on Azure however we need to tweak it to read as under:-
svar app = require('express')();
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function () {
console.log('Express server listening on port ' + server.address().port);
});
var io = require('socket.io')(server);
Hope this helps another dev out there trying to host the sample tutorial onto Azure!
Team Cennest!!!