在Windows Azure上运行弗莱克(或)的WebSocket服务器 [英] Running Fleck (or any) Websocket server on Windows Azure

查看:230
本文介绍了在Windows Azure上运行弗莱克(或)的WebSocket服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想运行的WebSocket服务器关闭在Azure中的辅助角色。

I would like to run a WebSocket server off a worker role in Azure.

这在当地正常工作在模拟器上,但有一个Windows防火墙提示socket服务器运行的第一次。

This works fine locally on the emulator, but there is a windows firewall prompt the first time the socket server runs.

我不知道是否有人会知道如何克服在Azure上关于插座的连接问题。

I'm wondering if anyone would know how to overcome the connection issues with regards to sockets on Azure.

我的socket服务器的实现:的OnStart

My socket server implementation: OnStart

var server = new WebSocketServer("ws://theappname.cloudapp.net:8080/");

server.Start(socket =>
{
    socket.OnOpen = () =>
    {
        Trace.WriteLine("Connected to " + socket.ConnectionInfo.ClientIpAddress,"Information");
         _sockets.Add(socket);
    };
});
.... etc

客户端实现:

var socket = new WebSocket("ws://theappname.cloudapp.net:8080");

socket.onopen = function () {
    status.html("Connection Opened");
};
socket.onclose = function () {
    status.html("Connection Closed");
}


的状态更改为关闭加载页面后几秒钟。

我的端点下面的辅助角色:

My endpoint for the worker role below:

的WebSocket中输入http:8080 LT;不集>

我现在已经尝试使用绑定到内部IP地址如下:

I have now tried to bind to the internal IP address using the following:

<$c$c>RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[\"WebSocket\"].IPEndpoint.ToString();

SOLUTION

有关其他人面临这个在Azure上实现的WebSockets时的缘故;

For the sake of anyone else facing this when implementing websockets on Azure;


  1. 您的防火墙可能会拒绝你的连接,如果不是在端口80或8080,以便为它创建一个单独的部署。

  1. Your firewall probably will deny your connection if not on port 80 or 8080 so create a separate deployment for it.

端点必须设置为TCP和不是HTTP为正确的防火墙规则。 (见图片)

Endpoint must be set to TCP and not HTTP for the correct firewall rules to be created. (see image)

推荐答案

刚刚受审的缘故,你为什么不从HTTP,以TCP协议更改输入Endpoit。和本地端口明确设置为8080(在你的情况)。另外你必须记住,Windows Azure的负载平衡器会杀死被idleing超过60秒无任何连接,所以你可能想实现某种平解决方案,以保持连接打开。

Just for the sake of trial, why don't you change your Input Endpoit from "http" to "tcp" protocol. And explicitly set the local port to 8080 (which in your case is ). Also you have to keep in mind that Windows Azure Load Balancer would kill any connection that is idleing for more than 60 seconds, so you might want to implement some kind of "ping" solution to keep the connection open.

这篇关于在Windows Azure上运行弗莱克(或)的WebSocket服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆