0

Nodejs server works like a champ locally. When deployed to Azure Web App, it fails with server error: isnode encountered an error when processing the request.

HRESULT: 0x6d HTTP status: 500 HTTP subStatus: 1013 HTTP reason: Internal Server Error You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'. ...

No real info here, so turned to the logs... where I see:

Fri Jul 24 2015 01:17:32 GMT+0000 (Coordinated Universal Time): Unaught exception: TypeError: Object \.\pipe\b9a229c1-7e20-4d2a-9f2d-fec75412cede has no method 'listeners' at Server.attach (D:\home\site\wwwroot\node_modules\socket.io\node_modules\engine.io\lib\server.js:358:26) at Function.attach (D:\home\site\wwwroot\node_modules\socket.io\node_modules\engine.io\lib\engine.io.js:124:10) at Server.listen.Server.attach (D:\home\site\wwwroot\node_modules\socket.io\lib\index.js:226:21) at new Server (D:\home\site\wwwroot\node_modules\socket.io\lib\index.js:51:17) at Function.Server (D:\home\site\wwwroot\node_modules\socket.io\lib\index.js:39:41) at Object. (D:\home\site\wwwroot\server.js:11:17) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12)

Tracing that back, I think the line of interest is:

at Object. (D:\home\site\wwwroot\server.js:11:17)

In the nodejs server code:

var socket = io.listen(process.env.port || 3000);

So I'm guessing the failure is possibly due to versioning or something? I can't seem to get any socket.io app to work on azure web deployment as cloud service or cloud app.

Anyone else?

TomO
  • 458
  • 2
  • 9
  • 20

1 Answers1

0

Can you post the rest of your code? The initialization of your io variable is important to understanding what went wrong.

Your code should look something like this when initializing if you are using Express 4

var app = require('express')();

var server = require('http').Server(app);
var io = require('socket.io')(server);
// Get the port that we should be listening on
server.listen(process.env.PORT || 8080);

Inside your config, when using IISNode you need to specify that you are using Socket.io by adding the following to your <handlers> element in your Web.config:

<add name="iisnode-socket.io" path="server.js" verb="*" modules="iisnode" />

Additionally, we need to let IISNode know how to direct our Socket.io requests by adding a new rewrite rule:

<rewrite>
  <rules>        
    <rule name="SocketIO" patternSyntax="ECMAScript">
      <match url="socket.io.+" />
      <action type="Rewrite" url="server.js"/>
    </rule>
  </rules>
<rewrite>

Also check and see if the socket.io package properly installed on your server instance.

Here's an answer I wrote about getting IISNode working in IIS using Socket.io and Virtual Directory usage as well.

Community
  • 1
  • 1
peteb
  • 18,552
  • 9
  • 50
  • 62