Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning Fleck (or any) Websocket server on Windows Azure
    text
    copied!<p>I would like to run a WebSocket server off a worker role in Azure.</p> <p>This works fine locally on the emulator, but there is a windows firewall prompt the first time the socket server runs.</p> <p>I'm wondering if anyone would know how to overcome the connection issues with regards to sockets on Azure.</p> <p>My socket server implementation: <code>OnStart</code></p> <pre><code>var server = new WebSocketServer("ws://theappname.cloudapp.net:8080/"); server.Start(socket =&gt; { socket.OnOpen = () =&gt; { Trace.WriteLine("Connected to " + socket.ConnectionInfo.ClientIpAddress,"Information"); _sockets.Add(socket); }; }); .... etc </code></pre> <p>The client implementation:</p> <pre><code>var socket = new WebSocket("ws://theappname.cloudapp.net:8080"); socket.onopen = function () { status.html("Connection Opened"); }; socket.onclose = function () { status.html("Connection Closed"); } </code></pre> <hr> <p>The status changes to <code>closed</code> a few seconds after loading the page.</p> <hr> <p>My endpoint for the worker role below:</p> <p><code>WebSocket Input http 8080 &lt;Not Set&gt;</code></p> <hr> <p>I have now tried to bind to the internal IP address using the following:</p> <p><code>RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["WebSocket"].IPEndpoint.ToString();</code></p> <hr> <p><strong>SOLUTION</strong></p> <p>For the sake of anyone else facing this when implementing websockets on Azure;</p> <ol> <li><p>Your firewall probably will deny your connection if not on port 80 or 8080 so create a separate deployment for it.</p></li> <li><p>Endpoint must be set to TCP and not HTTP for the correct firewall rules to be created. (see image)</p></li> </ol> <p><img src="https://i.stack.imgur.com/EF12A.jpg" alt="Endpoint Configuration"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload