1
votes

I am building windows azure application which is primarily based on .NET, but I also have to build a socket.io server using node.js hence i need to deploy a socket.io server and use this socket.io url to connect in my .NET application.

I followed all the steps listed here . And I am able to get the socket.io running on my local but when i deploy to cloud, it doesnt start. Please find below a code snippet for socket.io

var app = require('express')()
  , server = require('http').createServer(app)
  , io = require('socket.io').listen(server, { origins: '*:*' });

server.listen(4001);

When i hosted it in my local emulator, 127.0.0.1:81 was pointing to this in my browser enter image description here

But 127.0.0.1:4001 showed "Cannot GET /" on the browser, which is an indicative that the socket.io server is running on that url.

But when i deploy the same to cloud, i get the same as the screenshot on the url where the cloud service is hosted but on port 4001 where the socket.io server should have started it says page cannot be displayed.

Please let me know if you need to see any other files like web.config etc.

I have been stuck on this issue from forever and its really crucial for my project, any suggestions or ideas would be deeply appreciated.

Thanks

1
Did you follow all of the steps here: windowsazure.com/en-us/develop/nodejs/tutorials/…WiredPrairie
I followed the steps in the link you provided and tried deploying the same chat app that the tutorial mentioned and i am still getting the error that is displayed in the screenshot attached above. It works perfectly fine on my local emulator. Could it be a problem with the node.js version? My local has 8.21 and i saw in the ServiceConfiguration settings file that azure was trying to install 6.20 on the cloud service. Any idea?Bitsian

1 Answers

0
votes

The important part that you are missing from the sample is setting of the port number

var port = process.env.port || 1337;

and .listen(port)

when you are running inside of the Azure environment (even emulated) the ports are assigned for you, the port environment variable will tell you where. 4001 is likely not the assigned port.

The 1337 would only be used if you are running by executing

node server.js

from the command line