I am trying to implement socket.io into my application which is hosted at Azurewebsites. webapp
Here is the server.js
var app = require(\'ex
Per my experience, Azure Web App doesn't bind loaclhost
or 127.0.0.1
to your website, and only ports 80 and 443 are public-facing. This maps to a specific port for your app to listen to, retrievable via process.env.PORT
. So you'd need to replace
var socket = io('http://localhost:3001');
with
var socket = io('http://<your app name>.azurewebsites.net');
And if your server side and client side in the different domain, you'd also need to enable CORS on the server side. In Azure, we can enable it with the Azure portal.
Socket.IO uses WebSockets, which are not enabled by default on Azure. You can also enable WebSocket support using the Azure Portal. Please see the steps below.
For more info, please refer to this documentation.