1

I create Node.js Socket.io app with Visual Studio. It works fine locally. When I publish it as Azure app getting error:

"The page cannot be displayed because an internal server error has occurred."

Does anybody know what is the problem, I am thinking about port 80 which is only open port for Azure app (+ 443).

I tried to listen to port 80 , but again the same error.

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Armen Khachatryan
  • 831
  • 3
  • 22
  • 37
  • When I hosted a socket.io app on Azure I had to use the Azure app that was specifically for "Node.JS applications" – pay Jul 26 '16 at 15:45
  • Did you create it from Azure dashboard, instead of Visual Studio create it by default when publish? – Armen Khachatryan Jul 26 '16 at 15:47
  • Yes I created the Node.js app from the Azure dashboard, and then if I remember correctly, used a specific GIT deployment URL that I put into VS – pay Jul 26 '16 at 15:49
  • Can you please tell me the template name? Thanks! – Armen Khachatryan Jul 26 '16 at 15:49
  • There is an option when you create a "New" item in Azure: Node JS Empty Web App. Also check here: https://github.com/Azure/azure-content/blob/master/articles/app-service-web/web-sites-nodejs-develop-deploy-mac.md I used the GIT url to deploy from VS – pay Jul 26 '16 at 15:53
  • Thank you very much, problem solved! – Armen Khachatryan Jul 27 '16 at 20:32

2 Answers2

2

To build a socket.io application on Azure Web Apps, there are several attentions you should pay on:

  • Node.js server listening port should be set similar toprocess.env.PORT || 3000`

  • Verify web.config settings, confirm <webSocket enabled="false"/> to disable the IIS WebSockets module, which includes its own implementation of WebSockets and conflicts with Node.js specific WebSocket modules such as Socket.IO.

Please refer to https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-chat-app-socketio/ for more details.

Any further concern, please feel free to let me know.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Liu , I need to create a file known as web.config and need to add `` to disable IIS? My app is using polling instead of WebSockets, please help me... – Abishek P.Y Aug 09 '20 at 05:35
1

Azure App Service uses IISNode to talk to node.exe processes. This happens over named pipes. Configure your application to use the named pipe instead of a socket.

i.e.

Replace

app.set('port', 3000);

by

app.set('port', process.env.PORT || 3000);

Enable WebSockets in the Portal, restart the Web App and you should be up and running.

[ Gary Liu is right, that setting is not needed. However using a sample Socket.IO chat implementation on App Service, Socket.IO doesn't seem to care about how i set "WebSockets" in the portal. Works either way. ]

Since Internal Server Error is the computing equivalent to There is a fault in the observable Universe you should also enable logging for your Node application, at least for the development phase:
From https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-debug/:

To enable developer errors, add the following line to the IISNode.yml file:

devErrorsEnabled: true

Once this option is enabled, IISNode will return the last 64K of information sent to stderr instead of a friendly error such as "an internal server error occurred".

More on iisnode: http://www.jokecamp.com/blog/getting-started-with-iisnode/
More on named pipes: What are named pipes?

Community
  • 1
  • 1
evilSnobu
  • 24,582
  • 8
  • 41
  • 71