How Can I open websocket port on azure?

2019-09-13 00:16发布

问题:

I want to create live chatroom by BrainSocket.I follow from this tutorial ,and it's work well on my localhost.When i deploy on ubuntu 14.04 on azure virtual machine it not work. Chrome Inspect is tell me error on this part of my code

 app.BrainSocket = new BrainSocket(
                    new WebSocket('ws://myappname.cloudapp.net:8080'),
                    new BrainSocketPubSub()
            );

it's tell ws://myappname.cloudapp.net:8080 is return 404 not found... I guess it should be web socket port problem on Azure. How can I open web socket port 8080 on Azure virtual machine ?

回答1:

You have to add an Endpoint to your virutal machine. Go to Management Portal/Your_VM/Endpoints and click add new. Your endpoint configuration should look similar to this:

Detailed instruction can be found here http://azure.microsoft.com/en-gb/documentation/articles/virtual-machines-set-up-endpoints/