1

我正在使用 WebsocketSharp 网络标准库来创建一个 websocket 服务器。在我的 Web 应用服务中,Websocket 已启用。始终开启已启用。当我在本地运行此服务器时,我可以零问题地使用它。一旦我部署到 Azure Web App Service,我最终会收到一条错误消息,指出我正在访问一个禁止的端口:

Unhandled exception. System.InvalidOperationException: The underlying listener has failed to start.
 ---> System.Net.Sockets.SocketException (10013): An attempt was made to access a socket in a way forbidden by its access permissions.
   at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
   at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Bind(EndPoint localEP)
   at System.Net.Sockets.TcpListener.Start(Int32 backlog)
   at System.Net.Sockets.TcpListener.Start()
   at WebSocketSharp.Server.WebSocketServer.startReceiving()
   --- End of inner exception stack trace ---
   at WebSocketSharp.Server.WebSocketServer.startReceiving()
   at WebSocketSharp.Server.WebSocketServer.start(ServerSslConfiguration sslConfig)
   at WebSocketSharp.Server.WebSocketServer.Start()
   at socket_uph.Program.Main(String[] args) in C:\Users\CFarley\source\repos\socket-uph\Program.cs:line 25

到目前为止,我的代码是:

public class Program
{
    public static void Main(string[] args)
    {
        var wssv = new WebSocketServer(80);
        wssv.AddWebSocketService<ClientService>("/client");
        wssv.AddWebSocketService<DataService>("/data");
        wssv.Start();  //LINE 25
        while (true)
        {}
    }
}

当我发布时,构建和发布成功,但由于上述错误,应用程序无法启动。

4

0 回答 0