在ASP.NET应用程序中运行Fleck服务器

时间:2016-04-14 12:51:04

标签: c# asp.net azure websocket server

我正在尝试在ASP.NET应用程序中托管websocket服务器,如下所示:

Global.asax中

protected void Application_Start(object sender, EventArgs e)
{
    var server = new WebSocketServer("ws://127.0.0.1:8080");
    Server.Start(socket => socket.OnOpen = () => OnUserConnect(socket));
}

private void OnUserConnect(IWebSocketConnection socket)
{
    // Some application logic.
}

当我在计算机上测试我的应用程序时,一切都很好,我可以连接到此服务器。但是,当我将此应用程序部署到Azure时,我得到超时错误。那么,我想我只需要提供在Azure Web App中打开的适当端口?如果答案是肯定的,那么适当的端口是什么?

修改

我尝试将端口更改为80,我遇到了这个错误:

System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions

所以我想,这个端口也不对,或者我必须添加一些东西来配置(不过,我已经在我的Web App设置中启用了WebSockets)。

0 个答案:

没有答案